1、下载5.7.27,https://downloads.mysql.com/archives/community/
2、规划程序目录,basedir= /opt/mysql57
3、规划运行目录,datadir = /opt/mysql/data tmpdir = /opt/mysql/tmp tmpdir = /opt/data/tmp log_error = /opt/mysql/logs/error.log
4、创建用户和组,groupadd mysql useradd -g mysql mysql -s /sbin/nologin
5、初始化数据库,./mysqld --defaults-file=/opt/mysql57/my.cnf --initialize
6、查看root密码,tail -f -n500 /opt/mysql/logs/error.log
7、配置环境变量,vim /etc/profile export PATH=$PATH:/opt/mysql57/bin source /etc/profile
8、启动mysql服务,/opt/mysql57/bin/mysqld_safe --defaults-file=/opt/mysql57/my.cnf &
9、登录mysql ,mysql -uroot -p -S /opt/mysql/mysql.sock
10、修改root密码,set password=password('密码')
11、允许远程登录,GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
12、加入系统服务