MySQL5.7初始密碼檢視及重置
安裝了mysql5.7之後初始密碼不再預設為空
1.檢視初始密碼:
[[email protected]_225_102_centos ~]# grep 'temporary password' /var/log/mysqld.log
2016-07-08T02:25:46.311098Z 1 [Note] A temporary password is generated for [email protected]: MtPqF0/oN5zo
即初始密碼為 MtPqF0/oN5zo (密碼是隨機產生的,每臺機器產生的都不一樣哦)
或者
另外一種方法檢視預設密碼:
[[email protected]
# The random password set for the root userat Fri Jan 10 20:00:34 2014 (local time): aJqZsA2m
這裡的aJqZsA2m就是生成的root隨機密碼啦
2.登入及修改密碼:
[[email protected]_225_102_centos ~]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.11
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
登入之後 第一步必須先修改密碼,否則其他操作都執行不了。
修改密碼的方法:
mysql> alter user [email protected] identified by 'tyzZ001!';
Query OK, 0 rows affected (0.00 sec)
新修改的密碼中 必須包含 大小寫字母數字及符號
發現有些不支援上述方法 另提供一種思路