自动生成临时密码后无法访问MySQL

问题描述:

我已经擦除并安装了OSX 10.11 El Capitan,并且一直通过针对Mac OS X 10.9(x86,64位),DMG存档的MySQL (适用于10.11,他们在本教程中建议).当我完成安装MySQL时,我收到一条消息,提示:

I have erased and installed OSX 10.11 El Capitan and I have been following through this tutorial to get MySQL up and running on the new OS X. The first step was to download MySQL For Mac OS X 10.9 (x86, 64-bit), DMG Archive (works on 10.11, they recommended in the tutorial). While I were finishing installing the MySQL, I got the message saying that :

2015-10-25T02:10:54.549219Z 1 [Note] A temporary password is generated for root@localhost: R>gFySuiu23U

If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.

那太奇怪了,我从未见过这样的信息.之后,我通过首选项窗格"启动了MySQL,然后在终端上使用/usr/local/mysql/bin/mysql -v命令进行下一步.我收到一条错误消息,说:

That was weird, I have never seen that kind of message. After that, I started MySQL via the Preference Pane and then use /usr/local/mysql/bin/mysql -v command on the terminal for another step. I got an error message saying that :

ERROR 1045 (28000): Access denied for user 'cheetah'@'localhost' (using password: NO)

我还尝试使用根用户名和空密码通过Sequel Pro访问数据库,我得到拒绝访问的消息,提示:

I have also tried to access database through Sequel Pro using root as username and blank password, I got access denied message saying that :

Unable to connect to host 127.0.0.1 because access was denied.

Double-check your username and password and ensure that access from your current location is permitted.

MySQL said: Access denied for user 'root'@'localhost' (using password: NO)

好的,我还再次尝试使用root作为用户名,但使用'R> gFySuiu23U'作为密码(由MySQL生成).我收到连接失败的消息,说:

Okay, I also tried this again using root as a username but 'R>gFySuiu23U' as a password (which was generated from MySQL). I got connection failed message saying that :

Unable to connect to host 127.0.0.1, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Your password has expired. To log in you must change it using a client that supports expired passwords.

我该如何解决这个问题?我记得MySQL从来没有自动生成过这样的临时密码,不是吗?

How could I solve this problem? I remember that MySQL has never got automatically generated a temporary password like this, hasn't it ?

尝试一下:

mysql -u root -h 127.0.0.1 -p
Enter password: (enter the random password here)

参考: https://dev.mysql.com/doc /refman/5.7/en/data-directory-initialization-mysqld.html

在此之后,您可以使用 ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-password';

Following this, you may reset your password using ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-password';