How to Solve Error #1045 in phpMyAdmin
#1045 Access Denied for user 'root'@'localhost' (using password: YES).
This may happen if your root@localhost
database user was not granted the necessary rights to access the database. Or if you provided a wrong password.
In this tutorial, you will learn how to solve this error for the WAMP local server using phpMyAdmin.
If you get the #1045 Access Denied...
in phpMyAdmin it will look like the image below:
Let’s learn how to get rid of it.
Step #1. Open Your MySQL Console
- Left click your WAMP icon located at the bottom right of your desktop.
- Click on MySQL Console.
Step #2. Enter the Provided Commands
If you have a password, you can ignore this part.
- Type in:
use MySQL;
- Press Enter.
- Set your MySQL password with the following command, replacing “EnterYourPasswordHere” with your new chosen password:
UPDATE mysql.user SET Password=PASSWORD("EnterYourPasswordHere") WHERE User="root";
- Press Enter.
- Flush the privileges by typing:
FLUSH PRIVILEGES;
- Exit by typing:
Exit
- Press Enter.
Step #3. Edit Your config.inc.php File
Using a text editor, such as Notepad++, open your config.inc.php file.
- Go to My Computer > C Drive > (Your Local Server Folder, WAMP/MAMP/XAMPP) > APPS > PHPMYADMIN > config.inc.php
- Find the following line of code:
$cfg['Servers'][$i]['password'] = ''; // MySQL password
- Change the
'password'
to the newly chosen password you created in Step #2. - Click Save.
Step #4. Access Your phpMyAdmin
- Go to http://localhost/phpMyAdmin and test your phpMyAdmin access.
Congratulations! You are now able to access your databases.
Additional Reading
- Guide to accessing MySQL using XAMPP
- Guide to accessing MySQL using MAMP
- Create a Database with cPanel and phpMyAdmin
- Import and Export Data With phpMyAdmin
What’s Next
Most major website platforms use MySQL as their default database. phpMyAdmin is a free software, written in PHP, which makes it easy to manage your MySQL databases.
Subscribe to our “How to Use phpMyAdmin to Manage MySQL” video class and learn how to install and use phpMyAdmin. This class will be a huge help to you if you use any PHP-based software.
I also wanted to mention that the config.inc.php file for Xampp is located in: localhost/xampp/phpmyadmin/config.inc.php
C:\xampp\phpMyAdmin
Here is the smart way to fix this error 🙂
go to the wamp [w] icon on right side of you desktop near the time.left click go to [mysql] left click [services] select [restart] and smile 🙂
if not restart your pc open browser and refresh the page 🙂
thanxxx it works..
I tried this..both restarting the mysql services and restarting the PC. Neither worked with Firefox.
it will not work that way, I spent half a day no one around here knows the simple answer to a simple question…you probably installed the MYSQL on your pc long time ago and had set a password that you forgot, neither of changing code works, all you need to do either remebmber the old password or unistal and install the MYSQL
how about this one:
#1045 – Access denied for user ‘root’@’localhost’ (using password: NO)
One of the possible reasons for this,
make sure that no other MySql is running other than the one in wamp. Check for the mysql running in task manager processes and kill it, before running the wamp. Later restart the wamp and the browser.(Be aware by killing the process the MySql(not in wamp) installed will not work, to make this work again goto mysql installed folder in bin you find mysqld application file run it, then your old mysql(not in wamp) will run again).
solved my problem thanks
Nice one thanks alot it really helped me
thanks. My problem, MAMP is running without Apache.
I am having problem plz help me out
what your problem like?
Thank you very much , solved my problem
Sure! Glad to hear our tutorial helped you. We just added some links to related tutorials and video lessons. Please check them out.
Cheers,
Alex
thank you so much the easiest and best answer thanks alot
it works, thanks
thank you so much
Greatest tutorial very very helpful
I installed WAMP and ended up changing the port to 8080. because another app was using port 80. That worked and I got Apache working fine. When I go to phpMyAdmin I get the:
#1045 – Access denied for user ‘root’@’localhost’ (using password: NO)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
I never logged into phpMyAdmin or set up a password so it should work fine… I try to use the MySql Console and when I try the suggested password it just closes, when I try no password, it just closes. I am the admin. Do you think it has to do with the port change? any suggestions?
This information was really useful, it helped us solve mysql related issue.
Thanks,
thank you so so so much!
You are AWESOME…! This worked like a charm! Thanks so much for taking the time to make this guide!
Thank you for this well stated, very straight forward solution to the 1045 error problem. After trying many other proposed solutions, to no avail, this is the one that worked on the first try.
I was searching for this answer whole my live,thanks
You’re truly a superstar… i liked the way you explained… easy steps…saved my time..hats off!
Thank you so much! Worked perfectly for me.
pretty nice solution..#thx 😀
there is still an error in using it .. i have dne all thiss,pls help me out
Thank you so much for sharing this useful information. this is really helpful to me and Now every thing is working fine.
Thanks again.
Thank you very much!! Perfect!!!
Thank you very much for this useful information. It really helped.
Hi, this worked. I should add that it didn’t work initially, I had to stop all services (on Wamp) and do a full restart of my computer before it finally worked. Might be because I have Window 7 on a partitioned section of my Mac system?? Thank you very much however. Saved my sanity.
GREAT SIR,,,ITS USEFULLL
Absolutely amazing! Thanks so much!
Thank You very much for this useful information…
Hello sir,
I could not set password in command prompt. when i run mysql.exe file there also i got same error when i run on browser. that is access denied for localhost user.
Please help me how to solve this error
Thanking you in advance
It might because u have forget your old password that u have set long long time ago. U can go to previous website projects php files to check the database username and password that open connection of database for your php files.
thanks,great work
The fix worked great, but if you’re running WAMP with windows 7 you might need to clear your browser history and run WAMP as administrator.
You saved me my man. Thank you so much
Thanks man. You are indeed good at what you do. thank you once again. you are the man.
Need HELP! PLEASE: After installing a local server using WAMP and trying to access phpMyAdmin, I encountered error: #1045 Access Denied for user ‘root’@’localhost’ (using password: YES). I followed Tessa Mero’s instructions described in “How to Solve Error #1045 in phpMyAdmin – June 06, 2012 | Written by Tessa Mero” After typing UPDATE mysql.user SET Password-PASSWORD(“root”) WHERE User=”root”; mysql responed “Query OK, 3 rows affected. Rows matched:3 Changed:3 Warnings:0”. Then I typed FLUSH PRIVILEGES:, mysql responded “->”. What should I type from here? I am a beginner, please tell me what to do:
mysql> FLUSH PRIVILEGES:
->
THANKS in advance
Mysql will always do this, it’s basically asking you to keep going with the statement because you haven’t ended the statement with “;”.Â
try this:Â
FLUSH PRIVILEGES;
Instead of:Â
FLUSH PRIVILEGES:
Just sent a message to ask for help regarding what to do after mysql> FLUSH PRIVILEGE:
->
I fixed the problem by fixing my typing error (“;” instead of “:”). That “:” created a syntax error and mysql returned “->” expecting a new line. Anyway, my problem is fixed and I am inside phpmyadmin now. Thanks!
work fine in my wamp sever. but log in page not show when start first. please any one help me? thanks lot.
Thank you a thousand times!
Done! Thank you very much. You solve this problem
Awesome… Thank u very much. It worked for me and saved a big trouble.
It is really very valuable
Done!
Thanks
Error is same but it’s showing (using password: no)
and this solution is not working.
Is there any other solution?
hi there
deleted a database from phpadmin then got the error msg
the troubble is i dont have a password to put into msql.exe
as anything i put there says acess denied
Had the same error…
I did not change anything in configuration file.
Just changed
My Chrome->Prop->Target value
From : “C:\Program Files\Google\Chrome\Application\chrome.exe” –disable-web-security
To : “C:\Program Files\Google\Chrome\Application\chrome.exe
no still i done all the changes its not happening ..still acces denied only im getting
you rule indeed
The additional features for working with linked tables have been deactivated. how to solve this problem
Thanks so much! For some reason it didn’t have a root user at all, only controluser (with no privileges). This, however, created the root user (I think it was the FLUSH PRIVILEGES-command that did it)
For anyone who still gets the same error message screen after applying above steps, trying clearing your web browser cache.
Hello every one i lost my config.inc.php file please tell me now what can i do ? how can i recover or install same file in phpmyadmin ??? Please do help me..
Many thanks great help Tessa …
Thank you! This works
I followed all of your steps but get this when entering https://localhost/phpMyAdmin/ into my browser: ‘This webpage is not available’
thanks it works 🙂
#1273 how to solve it
I had the same problem and none of this solutions works with me. Finally I realized that I was separately installed mySQL server 5.1 in to my PC. Uninstall it and then works fine along with the wamp default privileges. Thanks for the fix mentioned here. That was helpful too.. 🙂
mind blowing ! 😀