I start my MAMP and try to connect to my MySQL server via localhost
or 127.0.0.1
, I tried all the possible password that I think it is correct, but for some reasons it still didn't like it, so I think I forgot it somehow. I need help.
Try #1
Enter all the possible passwords
MySQL -u root -h localhost -p
Enter password: <---I've tried almost 10 possible passwords
I got
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Try #2
Enter possible passwords
MySQL -u root -h localhost
I got
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Try #3
MySQL.server stop
I got
ERROR! MySQL server PID file could not be found!
I'm trying to run this
mysqld_safe --skip-grant-tables &
I got
Try #4
mysqld_safe --skip-grant-tables &
I got
[1] 72194
Follow those instructions and you should be fine:
https://svendeswan.wordpress.com/2016/01/26/mysql-reset-root-password-without-knowing-it-mac-mamp/
which is based on this one:
https://www.tech-otaku.com/local-server/resetting-mamp-mysql-root-user-password/
Please follow the steps in same sequence.
Make sure, your MySQL server is down. Execute below command :
Then, start MySQL server in safe mode
Then, connect to MySQL using
root
user.Change the database from
none
tomysql
Update both
authentication_string
andpassword
column with same password as shown below (if you get column not found error then remove one )Now, stop everything including
MySQL
server and MAMP application as well.And, search for
config.inc.php
file inside your MAMP folder (you could use command + space and search this file).You may not have privilege to change this file. After updating the privilege of the file you need to look for
$cfg['Servers'][$i]['password']
and update the password value as shown below.Save this file and restart everything in normal mode. And try connecting
root
user with new password as shown below :This is how you can do it in macOS Sierra, probably you install it via pkg and in the system preferences have an icon for MySQL, something like this:
If is up and running open a terminal and run this command:
That will help you to find the path of
mysqld
and the current command used to start the server, the output could be something like this:Next step is to stop MySQL, you can do this by clicking on the System Preferences menu and click on the
Stop MySQL Server
button, Once is stoped within a terminal you will need to start again the server but with some extra options, something like this:It is indeed the same command from the output of
pgrep -fl mysql
but in this case, you just need to add:After doing that you will notice that the menu from the System Preferences is Green again and MySQL should be up and running, now you can try to login and change password:
Stop and start again MySQL from the System Preference panel and it should be working now with the new password.
You have to reset the MySQL root password as follow :
And then, you will be able to connect using : mysql -u root -p Your password