Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlisha D
9,654 PointsMAMP phpMyAdmin error #1045 after I changed my root password. Not sure how to change it back/reset.
Was working through the Bootstrap to Wordpress project, and had everything up and running, until I changed the password of the database. The password and user were both set to 'root' as in the video, before I edited everything.
When I click on phpMyAdmin from the MAMP start page I get the following error:
1045 - Access denied for user 'root'@'localhost' (using password: YES)
I've checked google/you tube/stack overflow and can't find a solution which I understand.
When I go to localhost in a browser, I can still access and edit the localwp site I set up from the Local Wordpress Development project. When I click on my bootstrap_to_wp folder in the directory it displays 'error establishing a database connection'.
Is there a way to undo my actions?
15 Answers
cpauciello
26,629 PointsTo shutdown MAMP's MySQL server from the terminal you unfortunately need to use the root user/password
/Applications/MAMP/Library/bin/mysqladmin -u root -p shutdown
Without that, it yells at you.
$ /Applications/MAMP/Library/bin/mysqladmin shutdown /Applications/MAMP/Library/bin/mysqladmin: shutdown failed; error: 'Access denied; you need (at least one of) the SHUTDOWN privilege(s) for this operation
Instead just go ahead and click the 'stop servers' button in MAMP.
or
If you have the 'Stop Servers when Quitting MAMP' selected under preferences, you can just go ahead and quit MAMP to stop it.
With the MAMP servers stopped, you can start the MySQL server from the terminal using the MySQL Server Startup Script with the options --skip-networking-tables for unrestricted access to all of the databases and --skip-networking to stop remote access.
Copy and paste the following into the terminal and press enter.
/Applications/MAMP/Library/bin/mysqld_safe --skip-grant-tables --skip-networking --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid &
Something similar to the following should pop up in your terminal, press enter when it does to get back to the command prompt.
YourUsername at YourComputer in ~
$ 140529 01:36:32 mysqld_safe Logging to '/Applications/MAMP/db/mysql/nopenopenope.err'.
140529 01:36:32 mysqld_safe Starting mysqld daemon with databases from /Applications/MAMP/db/mysql
You should now be able to access the MySQL client from the terminal by entering the following.
/Applications/MAMP/Library/bin/mysql
You should see a welcome message, and the command prompt replaced with the MySQL Command Prompt 'mysql>', like this:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.34 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
You can now change the root user password. Enter the following, replacing 'NewPassword' with the password of your choice. Then press return.
mysql> UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root';
Reload the privileges by typing the following, and press enter.
mysql> FLUSH PRIVILEGES;
You can now quit the MySQL Command Prompt by typing 'exit' or '\q'
mysql> exit
You'll be returned to the terminal, enter the following command to shutdown the MySQL Server. You'll be prompted to enter your new root user password.
/Applications/MAMP/Library/bin/mysqladmin --socket=/Applications/MAMP/tmp/mysql/mysql.sock shutdown -u root -p
cpauciello
26,629 PointsHoly moly, sorry! I wrote a whole post for you.. Not sure how I managed to not post it ( having a zillion tabs open all the time could explain it though. ). That's probably for the best though, I'll keep this one short.
1. Start MAMP
The MySQL server must be running to change the password, open and start MAMP now. keep it running until the end of this.
2. Mac Terminal
With the MySQL server running, open the terminal (located in '/Applications/Utilities') enter or copy/paste the following:
/Applications/MAMP/Library/bin/mysqladmin -u root -p password
You'll be prompted for a password. Enter the current password for the root user. If you changed it in phpMyAdmin, use that password.
YourUsername at YourComputer in ~
$ /Applications/MAMP/Library/bin/mysqladmin -u root -p password
Enter password:
Enter the new password you want to use, and confirm it.
YourUsername at YourComputer in ~
$ /Applications/MAMP/Library/bin/mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:
The password has been changed! Almost done.
You need to replace all occurrences of the old root password with the new one you just created. To keep it easy here are a list of the files, you can open them in your favorite text editor and search for 'root', changing '-proot' to '-pNewPassword', replacing 'NewPassword' with your own.
- /Applications/MAMP/bin/phpMyAdmin/config.inc.php
- /Applications/MAMP/bin/checkMysql.sh
- /Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
- /Applications/MAMP/bin/repairMysql.sh
- /Applications/MAMP/bin/stopMysql.sh
- /Applications/MAMP/bin/upgradeMysql.sh
Examples of the edited files: /Applications/MAMP/bin/checkMysql.sh
# /bin/sh
/Applications/MAMP/Library/bin/mysql_upgrade -u root -pNewPassword --socket=/Applications/MAMP/tmp/mysql/mysql.sock --force
/Applications/MAMP/bin/quickCheckMysqlUpgrade.sh
# /bin/sh
/Applications/MAMP/Library/bin/mysqlcheck --quick --check-upgrade -u root -pNewPassword --socket=/Applications/MAMP/tmp/mysql/mysql.sock mysql
/Applications/MAMP/bin/repairMysql.sh
# /bin/sh
/Applications/MAMP/Library/bin/mysqlcheck --all-databases --repair -u root -pNewPassword --socket=/Applications/MAMP/tmp/mysql/mysql.sock
/Applications/MAMP/bin/stopMysql.sh
# /bin/sh
/Applications/MAMP/Library/bin/mysqladmin -u root -pNewPassword --socket=/Applications/MAMP/tmp/mysql/mysql.sock shutdown
/Applications/MAMP/bin/upgradeMysql.sh
# /bin/sh
/Applications/MAMP/Library/bin/mysql_upgrade -u root -pNewPassword --socket=/Applications/MAMP/tmp/mysql/mysql.sock --force
phpMyAdmin line 87
/Applications/MAMP/bin/phpMyAdmin/config.inc.php
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = 'NewPassword'; // MySQL password
Stop and restart MAMP
I hope that works/makes sense, if you have any other questions, or if you get an error and need extra help LMK.
cpauciello
26,629 PointsI can't believe how many partial answers there are to this. Mad respect for keeping at it, I've seen people rage quit over having to do much less w/unix.
Should be able to get you back in using the MySQL client. If you have not tried it already? MySQL Documentation
Didn't want to throw how to do that in my previous post, it's already a lot to take in. Figured it'd be best to split it up.
cpauciello
26,629 PointsUpdated my previous post. Nothing embarrassing about asking questions by the way, especially not in this case since I assume hacking on the terminal was not part of the plan. haha.
Again if you receive any errors let me know, I know this one popped up a few times:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
To fix that, close MAMP and
killall -9 mysqld
or open the Activity Monitor Application ( in '/Applications/Utilities') and search for mysqld, select it, click the 'Force quit process' button and confirm that you want to quit mysqld.
cpauciello
26,629 PointsAre you using MAMP or MAMP Pro?
Would be more than happy to walk you through resetting the password, and getting you back into phpMyAdmin if you still need help?
Konrad Pilch
2,435 PointsExcellent!
cpauciello
26,629 PointsAwesome, Shouldn't take me long to get the info up.
I don't really use MAMP much, of course MAMP Pro comes with a button to solve this, which was why I asked haha.
You will have to use terminal. Nothin crazy though.
.....hopefully you're still with me, most people disappear if anything command prompt related is mentioned lol.
Alex Plaza
22,923 PointsWhat about uninstalling mamp and intalling it again? (without deleting your project files of course).
And! some pictures would help to help you. I guess :)
Alisha D
9,654 PointsThanks for the replies Alex and Chris.
Alex, I have tried uninstalling MAMP, but had the same problem when I opened the Start Page.
Chris, I'm using MAMP, not MAMP Pro. I'd be so grateful if you could please walk me through getting back into my phpMyAdmin :)
Konrad Pilch
2,435 PointsHI, could i ask you how was your journey from the past year? :)
Alisha D
9,654 PointsI attempted to follow a few posts using the terminal to correct the issue, but I think I was missing some fundamental commands here and there, so it'd be great if you could talk me through it :) Will do my best to keep up!
Alisha D
9,654 PointsThanks so much Chris!
So I tried all of my passwords and none of them work at the 'enter password:' stage. I remember using this command a few days ago, and once I entered the password it prompted me to enter a new password, which I did. That was where I stopped understanding the instructions and I didn't make the necessary updates to all the files.
Is it possible to override my mess or should I just throw my laptop out now?
Alisha D
9,654 PointsI'm sure this is embarrassingly simple, but can you please tell me the command to stop and restart mysql in my Terminal.
When I use
sudo /usr/local/mysql/support-files/mysql.server stop
sudo mysqld_safe --skip-grant-tables
It returns 'command not found'.
Alisha D
9,654 PointsSo I tried to shut it down from the Terminal, out of curiosity, and I got this response - even though I used the password that I use every time I stop the servers (which is the password for my account on my laptop).
/Applications/MAMP/Library/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
So just hit 'Stop Servers' in MAMP.
Alisha D
9,654 PointsWow I got so excited, I thought it worked but when I went to shut down the MySQL server the password I set didn't work. After I went entered the new root password I got this:
Enter password:
/Applications/MAMP/Library/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
Alisha D
9,654 PointsChris, I really really appreciate your help. I have the distinct feeling that I'm the problem and I can't possibly take up any more of your time. I will try to track down someone locally with a bit more experience than me to follow your instructions, and I'm sure they will have better luck.
Thanks again for your help and patience :)
Stephen Van Delinder
21,457 PointsAlisha, It looks like this thread was from a while ago. I am having the same issue over here and I was wondering how you ultimately fixed it.
At this point I have lost all of my tables and mySQL data from uninstalling MAMP and reinstalling it. I just want a fresh install of MAMP. I can access PHPmyAdmin upon installing MAMP fresh until I create a password for the root user, then I get 1045 errors. Any ideas?
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsI realize that this is an old post, but just in case anyone ends up i a similar situation (..just happened to me the other day), this enabled me to re-gain access to phpMyAdmin (and all of my databases):
$cfg['Servers'][$i]['password'] = '';
This link explains where to find your config.inc.php file: