Reputation: 35983
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'
Upvotes: 0
Views: 1534
Reputation: 41
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.
Upvotes: 1
Reputation: 1290
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
Upvotes: 5