mysql 5.7 初始化问题---空密码

percona mysql 5.7 初始化,由于 环境需要 mysql 初始化之后是空密码
场景复现:
mkdir mysql10888
mkdir binlog innodata innolog relaylog log cnf
/usr/sbin/mysqld --defaults-file=/data/mysql10888/cnf/mysql10888.cnf --initialize --initialize-insecure --datadir=/data/mysql10888/data --user=mysqldb 

报错:
2019-03-13T15:49:10.674060+08:00 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-03-13T15:49:11.016977+08:00 0 [Warning] CA certificate ca.pem is self signed.
2019-03-13T15:49:11.226013+08:00 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2019-03-13T15:49:11.453063+08:00 1 [ERROR] 1819  Your password does not satisfy the current policy requirements
2019-03-13T15:49:11.453149+08:00 0 [ERROR] Aborting

可以正常的启动,error日志也没有报错

使用空密码无法进入:
mysql -S /data/mysql10777/data/mysqld10777.sock -uroot -p -P 10777
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[mysqldb@mysql-dev004.soho.momo.com mysql10777]$ mysql -S /data/mysql10777/data/mysqld10777.sock
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

端口与进程正常。

尝试一:去掉密码验证:
   skip-grant-tables

进入mysql5.7 发现user表是空的
root@localhost:mysqld10777.sock:[(none)]>select user,host from mysql.user;
Empty set (0.00 sec)

root@localhost:mysqld10777.sock:[(none)]>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| undolog            |
+--------------------+
4 rows in set (0.00 sec)

少了sys库

百思不得其解,在google了很多文章说的都不对

尝试二、突然想到5.6和5.7 的密码验证模式不一样,关闭5.7 密码验证

[mysqld]
validate_password              = off

重新初始化
error日志:
2019-03-13T15:06:55.600940+08:00 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-03-13T15:06:56.010897+08:00 0 [Warning] CA certificate ca.pem is self signed.
2019-03-13T15:06:56.266208+08:00 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

登录:
mysql -S /data/mysql10888/data/mysqld10888.sock -uroot

关闭了密码,也不需要上来先设置密码了
root@localhost:mysqld10888.sock:[(none)]>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| undolog            |
+--------------------+
5 rows in set (0.00 sec)

sys库也有了 

root@localhost:mysqld10888.sock:[(none)]>select user,host from mysql.user;
+---------------+-----------+
| user          | host      |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys     | localhost |
| root          | localhost |
+---------------+-----------+
3 rows in set (0.00 sec)

猜想:
  估计是一个bug,mysql5.7是严格的密码策略使用空密码可能触发验证机制
上一篇:ECS体验


下一篇:K8S自己动手系列 - 2.4 - Service