一、安装Mysql5.7
1. 配置Mysql扩展源
rpm -ivh http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
2. MySQL GPG 密钥可能过期,改一下密钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
3. yum安装mysql
yum install mysql-community-server -y
4. 启动Mysql,并加入开机自启
systemctl start mysqld
systemctl stop mysqld
systemctl enable mysqld
5. 使用Mysq初始密码登录数据库
systemctl start mysqld
mysql -uroot -p$(awk '/temporary password/{print $NF}' /var/log/mysqld.log)
6. 修改数据库密码复杂等级
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
7. 修改密码
mysql> set password for root@localhost = password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)
8. 登录测试
[root@http-server ~]# mysql -uroot -proot
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
9. 可视化工具的登录授权:(如果授权不成功,请查看防火墙)
mysql > grant all on *.* to root@'%' identified by '数据库密码';
mysql > flush privileges;
10. 开放端口号
firewall-cmd --zone=public --add-port=3306/tcp --permanent
11. 重启防火墙并查看是否生效
firewall-cmd --reload
firewall-cmd --list-all
12. 连接测试