当前位置:Gxlcms > mysql > Centos6.7编译安装MySQL_MySQL

Centos6.7编译安装MySQL_MySQL

时间:2021-07-01 10:21:17 帮助过:30人阅读

# 安装依赖包
[root@localhost ~]# yum -y install gcc gcc-c++  autoconf* automake* zlib* libxml* ncurses-devel ncurses libgcrypt* libtool* cmake openssl openssl-devel bison bison-devel unzip wget

# 进入指定目录下载
[root@localhost ~]# cd /usr/local/src
[root@localhost ~]# wget http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.27.tar.gz

# 添加mysql运行账户
[root@localhost ~]# /usr/sbin/groupadd mysql
[root@localhost ~]# /usr/sbin/useradd mysql -g mysql -s /sbin/nologin -M

# 解压下载源码包
[root@localhost src]# tar zxvf mysql-5.6.27.tar.gz
[root@localhost src]# cd mysql-5.6.27

# 编译三步曲
[root@localhost mysql-5.6.27]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

[root@localhost mysql-5.6.27]# make && make install

# 复制mysql配置文件
[root@localhost mysql-5.6.27]# cp -rf support-files/my-default.cnf /etc/my.cnf

# 复制myssql启动管理文件
[root@localhost mysql-5.6.27]# cp support-files/mysql.server /etc/init.d/mysqld

# 赋权限
[root@localhost ~]# chmod 755 /etc/init.d/mysqld

# 添加开机启动
[root@localhost ~]# chkconfig --level 345 mysqld on

# 创建数据库存放目录
[root@localhost ~]# mkdir -p /data/mysql

# 给数据库目录权限赋给mysql用户
[root@localhost ~]# chown -R mysql:mysql /usr/local/mysql
[root@localhost ~]# chown -R mysql:mysql /data/mysql

[root@localhost ~]# cd /usr/local/mysql
[root@localhost ~]# ln -s /usr/local/mysql/bin/* /usr/sbin/

# 数据库初始化
[root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/data/mysql

# 启动数据库
[root@localhost ~]# /etc/init.d/mysqld start、

# 对数据账户进行基本安全设置
[root@localhost ~]# mysql_secure_installation

人气教程排行