linux:centos7
mysql版本:5.7.37
报错原文
GPG验证不通过(命令后添加 --nogpgcheck 绕过GPG验证成功安装 )
yum install -y mysql-community-server --nogpgcheck
出现此关键字 安装成功
Complete!
- mysql5.7之后不允许空密码登录,在my.cnf设置skip-grant-tables也不好使
- 这个密码记录在/var/log/mysqld.log文件中,使用下面的命令可以查看此密码:
cat /var/log/mysqld.log|grep 'A temporary password'
[root@ssg ~]# mysql -uroot -p
mysql> show databases
## 报错
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
## 设置完密码之后又报错
mysql> alter user 'root'@'localhost' identified by '123456'
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
这个与mysql验证码策略有关(validate_password_policy)
validate_password_policy有以下取值:
默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。 有时候,只是为了自己测试,不想密码设置得那么复杂,譬如说,我只想设置root的密码为123456。 必须修改两个全局参数:
## validate_password_length(密码长度)参数默认为8,我们修改为1
mysql> set global validate_password_length=1
Query OK, 0 rows affected (0.00 sec)
mysql> alter user 'root'@'localhost' identified by '123456'
Query OK, 0 rows affected (0.00 sec)
mysql> exit
mysql>mysql -uroot -p
Enter password:
mysql> show databases
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
安装成功
评论区