mysql 5 7 初始化問題 空密碼

2021-09-19 19:50:33 字數 3329 閱讀 4985

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)

[[email protected] 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是嚴格的密碼策略使用空密碼可能觸發驗證機制

mysql 5 7初始化預設密碼錯誤

我的mysql安裝根目錄為 c program files mysql mysql server 5.7 根目錄下的檔案my default.ini,拷貝到桌面後更改配置 basedir c program files mysql mysql server 5.7 datadir c program...

mysql5 7 初始化 修改密碼 遠端登入

一 window刪除老的mysql服務 sc delete mysql,刪除服務。二 新裝沒data目錄,執行後root密碼預設空 mysqld initialize insecure 三 window增加服務裡 mysqld install 四 修改密碼 mysqladmin u root pas...

mysql初始化密碼問題

檢視mysql初始化密碼 cat var log mysqld.log grep password登入並修改密碼 mysql uroot p alter user root localhost identified by root 不然會報如下錯誤 mysql use mysql error 182...