I am on OS X 10.9.5 and I did a reinstall of mysql2 and I provided a password during installation but it is not working when I run the command mysql -uroot -p. The result I get is: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Does someone know how I can reset the mysql password? I have been searching posts all day on how to fix my issues but nothing has helped.

  • OK, have you tried "mysql -u root -pmy_password"? Notice the space between -u and root and the lack of space between -p and the password. Finally, what is "mysql2"? If the worse comes to the worst, maybe you might have to reinstall? Apr 9, 2015 at 6:09
  • I never did it without the space, but it gave the same result when I did it with the space: Warning: Using a password on the command line interface can be insecure. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES). I will do another reinstall I guess since I have explored every other option it seems.
    – xps15z
    Apr 9, 2015 at 12:29

2 Answers 2


Here are the exact steps I had to run to get it working:

sudo /usr/local/mysql/support-files/mysql.server stop

sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

In new terminal:

mysql -u root  

UPDATE mysql.user SET Password=PASSWORD('my-new-password') WHERE User='root';  


sudo /usr/local/mysql/support-files/mysql.server start  
  • Why stop the MySQL server? Imagine it is a production instance and should not be stopped for such a reason.
    – BuahahaXD
    Feb 9, 2016 at 8:36

The steps for changing your root password are laid out in the MySQL documentation. Since you're on OS X, follow the instructions under section "B. Resetting the Root Password: Unix Systems"

  • Thanks. But I have read a lot of articles and posts, none have helped. I have been to those docs. And I ran into the error: ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'. I could be missing steps, but I have tried so many different "solutions" but nothing has worked.
    – xps15z
    Apr 9, 2015 at 3:34
  • The key is the option --skip-grant-tables.
    – Rick James
    Apr 9, 2015 at 3:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.