Mysql5.7.16安装过程
1.安装依赖包
1 yum -y install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison
2、安装boost库(对应版本高于或低于这个版本都有问题)
1 wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz 2 3 tar zxvf boost_1_59_0.tar.gz 4 mv boost_1_59_0 /usr/local/boost
3、添加mysql用户组
1 groupadd mysql 2 useradd -r -g mysql -s /sbin/nologin mysql
4、下载mysql源码包并安装
1 wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16.tar.gz 2 3 tar zxvf mysql-5.7.16.tar.gz 4 cd mysql-5.7.16 5 cmake -DCMAKE_INSTALL_PREFIX=/home/mysql -DMYSQL_DATADIR=/home/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost 6 make && make install
5.调整配置文件
1 mv /etc/my.cnf /etc/my.cnf.bak 2 cp /home/mysql/support-files/my-default.cnf /etc/my.cnf
6. 给安装目录设置权限
1 chown -R mysql:mysql /home/mysql
7.初始化数据库
1 /home/mysql/mysqld --initialize --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data
注:初始化后会生成默认密码,请记录下来
2016-02-17T03:16:36.869627Z 1 [Note] A temporary password is generated for root@localhost: kci!&lc?s8wE
8.启动mysql
1 cp /home/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld 2 chmod +x /etc/rc.d/init.d/mysqld 3 chkconfig --add /etc/rc.d/init.d/mysqld
service mysqld start
9、访问数据库
1 mysql -uroot -p
10、修改默认密码(不修改默认密码,将不能正常使用sql,必须修改)
1 alter user 'root'@'localhost' identified by '123456';