Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to access MySQL after it automatically generated a temporary password

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. 

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)

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) 

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. 

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

like image 639
Cheetah Felidae Avatar asked Oct 25 '15 04:10

Cheetah Felidae


People also ask

Why MySQL is not working after entering password?

It is because MySQL Server stop, may be you run another application that use the same port. Try to run MySQL Installer Community, and you will find the program that you have to reconfigure (blue text). Try to configure MySQL Server ant click Test Connection.

What is the default password for MySQL connection?

The default user for MySQL is root and by default it has no password.

How do I disable automatic password expiration for all users in MySQL?

To establish automatic password-expiration policy globally, use the default_password_lifetime system variable. Its default value is 0, which disables automatic password expiration.


2 Answers

Try this:

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

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

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

like image 155
Kumar Nitin Avatar answered Sep 18 '22 14:09

Kumar Nitin


This is what worked for me on OS X Yosemite running MySql v5.7 (installed from the .dmg).

cd /usr/local/mysql/bin ./mysql -u root -p --connect-expired-password 

(Enter the temporary password generated by the installer.)

This gets you into sandbox mode and mysql> prompt. Then set desired root password with SET PASSWORD:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mySuperSecretPassword'); 
like image 40
Lesley Avatar answered Sep 20 '22 14:09

Lesley