1、安装包
链接:https://pan.baidu.com/s/1amZbcl4er0X4tXxuBT8sog
提取码:0000
2、卸载自带的MySQL-libs
rpm -qa | grep -i -E mysql\|mariadb | xargs -n1 sudo rpm -e --nodeps
3、导入到Linux中
4、安装依赖
[root@node00 mysql]# sudo rpm -ivh 01_mysql-community-common-5.7.16-1.el7.x86_64.rpm
[root@node00 mysql]# sudo rpm -ivh 02_mysql-community-libs-5.7.16-1.el7.x86_64.rpm
[root@node00 mysql]# sudo rpm -ivh 03_mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
[root@node00 mysql]# sudo rpm -ivh 04_mysql-community-client-5.7.16-1.el7.x86_64.rpm
[root@node00 mysql]# sudo rpm -ivh 05_mysql-community-server-5.7.16-1.el7.x86_64.rpm
5、启动MySQL
如果遇到bug,https://blog.csdn.net/weixin_51090485/article/details/118487120
[root@node00 mysql]# sudo systemctl start mysqld
6、查看初始密码
看清楚日期、我是07-05所以我的初始密码是:9.>5o5vSzoY#
[root@node00 lib]# sudo cat /var/log/mysqld.log | grep password
2021-05-06T08:21:45.495185Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: A;Gj*p5<J):0
2021-07-05T03:46:51.694112Z 1 [Note] A temporary password is generated for root@localhost: 9.>5o5vSzoY#
7、登录
[root@node00 intall]# mysql -uroot -p'9.>5o5vSzoY#'
8、更改密码策略
mysql> set global validate_password_length=4;
mysql> set global validate_password_policy=0;
9、设置密码
mysql> set password=password("new password");
10、修改成任何客户端都可连接
mysql> use mysql
mysql> select user, host from user;
+-----------+-----------+
| user | host |
+-----------+-----------+
| mysql.sys | localhost |
| root | localhost |
+-----------+-----------+
2 rows in set (0.00 sec)
mysql> update user set host="%" where user="root";
mysql> flush privileges;
mysql> select user, host from user;
+-----------+-----------+
| user | host |
+-----------+-----------+
| root | % |
| mysql.sys | localhost |
+-----------+-----------+
2 rows in set (0.00 sec)