首先我们进到MySQL的bin目录下➜ cd /usr/local/mysql/bin
然后切换成root身份➜ bin sudo su
接着跨过权限的验证sh-3.2# ./mysqld_safe --skip-grant-tables &
以root身份登录MySQL./mysql -uroot
查看mysql数据库下的user表mysql> show columns from user;
密码存在该表中的authentication_string字段下,接下来就可以直接查看密码了。mysql> select authentication_string from user where User='root';
+-------------------------------------------+
| authentication_string |
+-------------------------------------------+
| *781D25322166DB7FF99BA4A1FA5ED30439A60DDE |
+-------------------------------------------+
1 row in set (0.01 sec)