Coding Tutorials and Blog Posts

How to Solve Error #1045 in phpMyAdmin

After installing a local server and trying to access phpMyAdmin, you could possibly encounter the error: #1045 Access Denied for user 'root'@'localhost' (using password: YES).

If root@localhost wasn't granted the necessary rights to access the database or you provided the wrong password, you will then encounter this error.

Following this tutorial will help guide you on bypassing this error, for any local host server using phpMyAdmin.

If you get an Error #1045 in phpMyAdmin it will look like the image below:

tutuploadsphpMyAdmin-Access-Denied.png

Step 1: Open your MySQL console.

tutuploadsmedia_1338949643300.png

Step 2: Enter the Provided Command Lines

tutuploadsmedia_1338949812597.png

If you have a password, you can ignore this part.

  • Type in: use mysql;
  • Press Enter.
  • Set your MySQL Password: UPDATE mysql.user

SET Password=PASSWORD("EnterYourPasswordHere")
WHERE User="root";

  • Replace "EnterYourPasswordHere" with your new chosen password.
  • Press Enter.
  • Flush the privileges: FLUSH PRIVILEGES;
  • Exit by typing: Exit
  • Press Enter.

Step 3: Open and edit your config.inc.php file located in your local server files

tutuploadsmedia_1338949961143.png
  • 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 this line of code: $cfg['Servers'][$i]['password'] = ''; // MySQL password
  • Change 'password' to the new chosen password you created from Step 2.
  • Click Save.

Step 4: Access phpMyAdmin

tutuploadsphpmyadmin7.png
  • You can access phpMyAdmin by going to http://localhost/phpMyAdmin/.
  • Congratulations! You are now able to access your databases. 

Comments

 
tessa
#1 tessa 2012-07-04 04:30

I also wanted to mention that the config.inc.php file for Xampp is located in: localhost/xampp /phpmyadmin/con fig.inc.php
 
 
waseem
#2 waseem 2012-10-11 10:05

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 :)
 
 
buha
#3 buha 2012-10-17 03:31

how about this one:

#1045 - Access denied for user 'root'@'localho st' (using password: NO)
 
 
lampard
#4 lampard 2012-10-17 19:37

thank you so much
 
 
Guest
#5 Guest 2012-10-26 13:16

Greatest tutorial very very helpful
 
 
Guest
#6 Guest 2012-10-30 00:21

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'@'localho st' (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?
 
 
Guest
#7 Guest 2012-11-22 07:27

This information was really useful, it helped us solve mysql related issue.

Thanks,
 
 
Prasadi
#8 Prasadi 2012-11-24 04:37

thank you so so so much!
 
 
Deelux
#9 Deelux 2012-11-27 13:07

You are AWESOME...! This worked like a charm! Thanks so much for taking the time to make this guide!
 
 
Bill T
#10 Bill T 2012-11-29 05:49

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.
 
 
mikail
#11 mikail 2012-12-04 15:13

I was searching for this answer whole my live,thanks
 
 
Pratik Goyal
#12 Pratik Goyal 2012-12-10 08:13

You're truly a superstar... i liked the way you explained... easy steps...saved my time..hats off!
 
 
Craiger
#13 Craiger 2012-12-13 00:17

Thank you so much! Worked perfectly for me.
 
 
chemic
#14 chemic 2012-12-15 15:33

pretty nice solution..#thx :D
 
 
carmen
#15 carmen 2012-12-16 06:48

GRACIAS!!!!!!!!!!!!!!!!!!!!!!!!

TANKS!!!!!!!!!!!!!!!!!!!!!!!!!!


ME SALVASTE LA VIDA GRACIAS BUSQUE DEMASIADO CÓDIGO HASTA QUE APARECIÓ TU LUZ Y ME ILUMINÓ MIL GRACIAS!!!!!!!!!!!!

You saved me THANK YOU!!!!!!!!!!!!
 
 
vinod chauhan
#16 vinod chauhan 2012-12-21 15:35

there is still an error in using it .. i have dne all thiss,pls help me out
 
 
ravi
#17 ravi 2012-12-23 05:24

Thank you so much for sharing this useful information. this is really helpful to me and Now every thing is working fine.

Thanks again.
 
 
Santos
#18 Santos 2012-12-24 15:12

Thank you very much!! Perfect!!!
 
 
myavila
#19 myavila 2013-01-16 13:26

Thank you very much for this useful information. It really helped.
 
 
Ruthine
#20 Ruthine 2013-01-17 10:00

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.
 
 
FAISAL
#21 FAISAL 2013-01-30 08:00

GREAT SIR,,,ITS USEFULLL
 
 
D
#22 D 2013-02-01 04:02

Absolutely amazing! Thanks so much!
 
 
Nadeesha
#23 Nadeesha 2013-03-02 12:45

Thank You very much for this useful information...
 
 
Sheela
#24 Sheela 2013-03-06 02:48

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
 
 
arshad nawaz
#25 arshad nawaz 2013-03-13 16:37

thanks,great work
 
 
davidah
#26 davidah 2013-03-18 13:43

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.
 
 
gaps
#27 gaps 2013-03-28 11:50

You saved me my man. Thank you so much
 
 
frederick
#28 frederick 2013-04-09 16:55

Thanks man. You are indeed good at what you do. thank you once again. you are the man.
 
 
Leslie Luke
#29 Leslie Luke 2013-04-17 15:59

Need HELP! PLEASE: After installing a local server using WAMP and trying to access phpMyAdmin, I encountered error: #1045 Access Denied for user 'root'@'localho st' (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-PASSWO RD("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
 
 
Leslie Luke
#30 Leslie Luke 2013-04-17 16:38

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!
 
 
mohid
#31 mohid 2013-04-22 04:31

work fine in my wamp sever. but log in page not show when start first.

please any one help me?

thanks lot.
 
 
Antonio Lacruz
#32 Antonio Lacruz 2013-05-12 16:30

Thank you a thousand times!
 

Add comment


Security code
Refresh

blog-ad

Start Online Training

Members get access to all our video training. That's 1,142 training sessions in Joomla, Drupal, WordPress and Coding.

Manage All Your Joomla Sites

adminicredible

With Admincredible you can update and manage all your Joomla sites. If you have 5 or 500 sites, Admincredible will make your life easier! Visit Admincredible.com.

Latest Comments

The License for Our Tutorials

All of our tutorials are published under the Creative Commons Attribution-NonCommercial license. This means:

  • You can re-use these tutorials.
  • You can modify these tutorials.
  • You must link back to our original tutorial.
  • You can't use these tutorials commercially.

Click here to read the full license.

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.