web开发环境搭建 第二篇CentOS7.2编译安装MySQL5.7.13

 


 

 

 

准备工作

yum -y install ncurses-devel cmake

 

下载地址

http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.13.tar.gz

 

开始安装

[root@localhost src]# wget http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.13.tar.gz
[root@localhost src]# tar -zxf mysql-5.7.13.tar.gz
[root@localhost src]# cd mysql-5.7.13
[root@localhost mysql-5.7.13]# groupadd mysql
[root@localhost mysql-5.7.13]# useradd -g mysql mysql -s /bin/false
[root@localhost mysql-5.7.13]# mkdir -p /usr/local/mysql
[root@localhost mysql-5.7.13]# mkdir -p /data/mysql
[root@localhost mysql-5.7.13]# chown -R mysql:mysql /data/mysql
[root@localhost mysql-5.7.13]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci​​ -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
[root@localhost mysql-5.7.13]# make
[root@localhost mysql-5.7.13]# make install
[root@localhost mysql-5.7.13]# cd /usr/local/mysql

 

上面这三步应该可以不要

 

[root@localhost mysql-5.7.13]# mkdir -p /usr/local/mysql
[root@localhost mysql-5.7.13]# mkdir -p /data/mysql
[root@localhost mysql-5.7.13]# chown -R mysql:mysql /data/mysql

 

配置

1、环境变量

 

[root@localhost mysql]# vim /etc/profile #编辑profile添加环境变量,在profile最后加上:​

#add by Tomener ~ nginx, mysql, openssl, php
export PATH=$PATH:/usr/local/nginx/sbin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/local/openssl/bin:/usr/local/php/bin

[root@localhost mysql]# source /etc/​profile

 

2、初始化MySQL

 

[root@localhost mysql]# mysqld --initialize --user=mysql

可能会出现的错误【错误1】​

[root@localhost mysql]# mysql_ssl_rsa_setup

 

3、修改密码

 

[root@localhost mysql]# ps -ef|grep mysql
[root@localhost mysql]# kill -9 mysqld进程号 #杀死mysqld进程,如果有的话
#或者停止掉mysqld服务:
[root@localhost mysql]# /etc/init.d/mysqld stop
[root@localhost mysql]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[root@localhost mysql]# mysql
mysql> update mysql.user set authentication_string=Password('123456') where user="root";
mysql> flush privileges;
mysql> quit;
下面这一步一定要做哦
mysql> mysql -u root -p
mysql> set password=Password('123456');
mysql> flush privileges;
mysql> quit;

 

4、复制启动脚本

 

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld​

 

5、开机自启​

 

[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig --level 35 mysqld on

 

 

 

参考文档

 

http://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html

 

 

 

编译参数

 

http://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html