Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset MySQL root password to "default" - MAMP

I changed my root level password on phpMyAdmin. I was unsure where to enter the password itself, as it did not give me the option (login form). I wondered if it was the php.ini file but users with read privileges could read it if I placed the password in there.

Now, the mysql doesn't run as I tried various online resources to fix the problem. If needs be I would delete mamp and re-install but I do not want to lose my database files. Ideally I would revert the password to default, which I believe was nothing, except now I cannot connect to phpmyadmin, or the mamp start page:

Error: Could not connect to MySQL server!

Any help would be great.

UPDATE -

Error message from mamp:

/Applications/MAMP/Library/bin/mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
like image 929
m33bo Avatar asked Apr 15 '13 14:04

m33bo


2 Answers

This seemed to have fixed it when using terminal to reset the password:

/Applications/MAMP/Library/bin/mysqladmin -u root -p password newpassword

Found on mamp faq.

like image 65
m33bo Avatar answered Oct 07 '22 21:10

m33bo


Look in the files:

  • checkMysql.sh
  • quickCheckMysqlUpgrade.sh
  • repairMysql.sh
  • stopMysql.sh

The important one in this case is "quickCheckMysqlUpgrade.sh". All the files are located in the /Applications/MAMP/bin/ directory.

In these files you'll find something like

# /bin/sh
/Applications/MAMP/Library/bin/mysqlcheck --quick --check-upgrade -u root -proot --socket=/Applications/MAMP/tmp/mysql/mysql.sock mysql

When you see -proot that is the password MAMP will try to use, -p{password}.

-p means "password" and whatever comes after is the password. So change "-proot" to eg. "-pmysecret" or whatever your password is.

like image 33
Christoffer Avatar answered Oct 07 '22 23:10

Christoffer