网上找到的有效答案:
密码在/var/log/mysqld.log这个文件里
可以用grep 'temporary password' /var/log/mysqld.log来查询,也可以自己在文件里找。
[root@YFPUNzLr ~]# grep 'temporary password' /var/log/mysqld.log
2017-02-15T14:31:05.449058Z 1 [Note] A temporary password is generated for root@localhost: 3NeI3PuNwa%j
[root@YFPUNzLr ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 10
Server version: 5.7.17
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>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…