Centos7安装Mysql5.7

由 admin 发布

Centos7安装Mysql5.7

别问我为什么不装Mysql8.0 怎么装怎么报错 所以放弃了

话不多说 直接上脚本

安装

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install mysql-server -y
systemctl start mysqld
systemctl enable mysqld

登录

grep 'temporary password' /var/log/mysqld.log    #获取默认密码
SET PASSWORD = PASSWORD('your_new_password');    #修改默认密码
CREATE USER 'root'@'%' IDENTIFIED BY 'your_new_password'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION #可选 允许root远程访问
FLUSH PRIVILEGES;                                #刷新权限

排坑日志

坑1.提示GPG密钥有问题

The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.

解决方案:

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

参考:

https://stackoverflow.com/questions/71239450/gpg-keys-issue-while-installing-mysql-community-server

https://dev.mysql.com/doc/refman/8.0/en/checking-rpm-signature.html

坑2.未重置mysql密码导致部分功能无法使用

You must reset your password using ALTER USER statement before executing this statement.

解决方案:

SET PASSWORD = PASSWORD('your_new_password'); 

参考:

https://stackoverflow.com/questions/33467337/reset-mysql-root-password-using-alter-user-statement-after-install-on-mac

https://dev.mysql.com/doc/refman/5.6/en/alter-user.html


暂无评论

发表评论