0

I've been trying to reset the password for MySQL but all of the solutions I've found, nothing seems to work. I'm using OSX Yosemite with MAMP and MySQL 5.6.20

I attempted to reset the password via MAMP to pass but it does not work

$mysql -u root -p Enter password: pass ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) $ 

and none of this works

$mysql -uroot ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) $mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) $mysql -u root@localhost Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 62 Server version: 5.6.20 Homebrew Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use magento ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'magento' mysql> SET PASSWORD FOR 'root' = PASSWORD('pass'); ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql' mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pass'); ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql' mysql> SET PASSWORD FOR 'root'@'::1' = PASSWORD('pass'); ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql' 

2 Answers 2

5

You can stop mysql server and restart it with --skip-grant-tables option. That way it doesn't look at credentials when opening up a mysql shell

After that,

mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass') -> WHERE User='root'; mysql> FLUSH PRIVILEGES; 

Stop mysql server, and start it again

Sign up to request clarification or add additional context in comments.

3 Comments

I attempted this but it still doesn't work. Updated question with details of attempt.
when opening the terminal after adding skip-grant-table, use mysql -u root
Ha that's one way I guess.
1

Just adding some details to Justin’s Kiang answer (which help me, thanks!). On my OS X Machine:

sudo /usr/local/mysql/support-files/mysql.server stop sudo /usr/local/mysql/support-files/mysql.server start --skip-grant-tables mysql -u root 

and then the SQL code as per Justin’s answer:

UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root'; FLUSH PRIVILEGES; bye 

And restarting the MySQL server again:

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

Adjust your path to mysql folder if needed.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.