1.部署
tar xf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.17-linux-glibc2.5-x86_64 /application/mysql-5.7.17
ln -s /application/mysql-5.7.17 /application/mysql
2.授权
chown -R mysql.mysql /application/mysql-5.7.17
3.初始化
/application/mysql-5.7.17/bin/mysqld --initialize --user=mysql --basedir=/application/mysql-5.7.17 --datadir=/application/mysql-5.7.17/data
记录初始密码(一定要记录)
A temporary password is generated for root@localhost: );xf/h%lm6iR
4.拷贝配置文件和启动文件
cp /application/mysql-5.7.17/support-files/my-default.cnf /etc/my.cnf
cp /application/mysql-5.7.17/support-files/mysql.server /etc/init.d/mysqld
5.修改启动文件内容
sed 's#/usr/local#/application#g' /application/mysql-5.7.17/bin/mysqld_safe /etc/init.d/mysqld -i
6.启动
/etc/init.d/mysqld start
7.修改root密码
mysqladmin -uroot -p password '123456'
8.设置开机自启动
chkconfig mysqld on
chkconfig --list mysqld
9.启动数据库
/etc/init.d/mysqld start
netstat -lntup|grep 3306
注意,因为-DMYSQL_UNIX_ADDR=/application/mysql-5.6.36/tmp/mysql.sock这条参数会导致找不到pid文件,创建参数指定的路径即可
10.设置环境变量(便于修改)
echo 'PATH=/application/mysql/bin/:$PATH' >>/etc/profile
tail -1 /etc/profile
source /etc/profile
echo $PATH
mysql
11.清理用户和无用的数据库(按个人环境清理)
select user,host from mysql.user;
drop user ''@'db01';
drop user ''@'localhost';
drop user 'root'@'db01';
drop user 'root'@'::1';
select user,host from mysql.user;
drop database test;
show databases
最后检查结果如下