第一步:去 www.mysql.com/downloads/, 下载相应版本呢的MySQL
第二步:确认是否安装过mysql
rpm -qa|grep mysql
如果有则先卸载
rpm -e --nodeps 包名称 逐一进行卸载
第三步:通过ftp 将下载 mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar 拷贝到 linux 某路径上
第四步:
解压文件 tar -xvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
建议去掉 mysql-community-test-5.7.28-1.el7.x86_64.rpm 否则找不到依赖无法安装
第五步:
在解压的路径运行命令
yum localinstall -y mysql-comm*
自动安装 出现 Complete!或者 完毕! 表示成功安装
第六步:
1. 运行命令:systemctl start mysqld 启动mysql
2. 通过 grep ‘temporary password’ /var/log/mysqld.log 查看密码
3. 通过 mysql -uroot -p 登陆
4. vi /etc/my.cnf 在[mysqld] 下加入一行 skip-grant-tables (可以不输入密码登录) 保存
5. 重启mysql 服务 systemctl restart mysqld
6. 直接 mysql 就可登陆
7. 运行命令修改密码 update user set authentication_string=password('你的密码') where user ='root';
8. 将/etc/my.cnf 里加入的一行去掉
9. 重启mysql 服务 systmectl restart mysqld
10. mysql -uroot -p 输入密码可登录
11. 必须修改密码不然无法操作 alter user ‘root’@‘localhost’ identified by ‘你的密码’;
第七步: 修改外部可连接到MySQL
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
第八步:解决 导入的sql文件过大 需修改以下配置
在 /etc/my.cnf 在[mysqld] 下加入一行 max-allowed-packet=300M 设置可接受文件的大小,
大小自己设定修改完毕后 重启mysql服务