1.创建mysql目录:mkdir /usr/local/mysql
2.从官网下载mysql安装包:wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
3.创建data目录:mkdir /usr/local/mysql/data/
4.解压缩mysql包:tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
5.移动: mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql
6.编译安装并初始化(记住最后的初始密码):/usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
7.软链接并启动mysql服务:
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
service mysql start
8.查看mysql:ps -ef|grep mysql
9.登录msyql,输入密码(密码为步骤7初始化生成的密码):mysql -u root -p password
10.修改密码并开发远程访问权限:
alter user 'root'@'localhost' identified by '123456';
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;
exit;
11.编辑my.cnf,添加配置文件:
vi /usr/local/mysql/my.cnf
[mysqld] port = 3306 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES