1.wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar 2.按照依赖关系依次安装rpm包 依赖关系依次为common→libs→client→server
代码语言:javascript复制rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm
安装报错:警告:mysql-community-common-5.7.22-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 解决方法:rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm --force --nodeps
3.启动
代码语言:javascript复制systemctl start mysqld.service 启动mysql
systemctl status mysqld.service 查看mysql状态
systemctl stop mysqld.service 关闭mysql
4.修改密码
代码语言:javascript复制查看密码:grep 'temporary password' /var/log/mysqld.log
更改策略,设置 validate_password_policy=0;
mysql> set global validate_password_policy=0; # 此时,新密码长度大于等于8位才有效,否则报错
修改有效密码长度:
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
不管设置 validate_password_length=1,还是2,3,4 ,‘使密码长度生效’这个参数的实际值都是4。超过4后设置是多少实际就是多少。
step2:重设密码:
mysql> set password for root@localhost=password('9527');
我的博客即将同步至腾讯云 社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=2jbyk87bgcaoc