How to Solve Error #1045 in phpMyAdmin

How to Solve Error #1045 in phpMyAdmin
After installing a local WAMP server and trying to access your phpMyAdmin, you may encounter the error:

#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:

tutuploadsphpMyAdmin-Access-Denied.png

Let’s learn how to get rid of it.

Step #1. Open Your MySQL Console

tutuploadsmedia_1338949643300.png

  • Left click your WAMP icon located at the bottom right of your desktop.
  • Click on MySQL Console.

Step #2. Enter the Provided Commands

tutuploadsmedia_1338949812597.png

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

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 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

tutuploadsphpmyadmin7.png

  • Go to http://localhost/phpMyAdmin and test your phpMyAdmin access.

Congratulations! You are now able to access your databases.

Additional Reading

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.

Author

0 0 votes
Article Rating
Subscribe
Notify of
guest

142 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
pankaj
pankaj
9 years ago
Reply to  Tessa Mero

C:\xampp\phpMyAdmin

waseem
waseem
12 years ago

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 🙂

preety
preety
11 years ago
Reply to  waseem

thanxxx it works..

frustrated
frustrated
9 years ago
Reply to  waseem

I tried this..both restarting the mysql services and restarting the PC. Neither worked with Firefox.

Erich Marti
Erich Marti
8 years ago
Reply to  frustrated

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

buha
buha
12 years ago

how about this one:

#1045 – Access denied for user ‘root’@’localhost’ (using password: NO)

Raviteja Panchagnula
Raviteja Panchagnula
11 years ago
Reply to  buha

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).

miyuru gomes
miyuru gomes
9 years ago

solved my problem thanks

Ikben
Ikben
7 years ago
Reply to  miyuru gomes

Nice one thanks alot it really helped me

Ryota Bannai
Ryota Bannai
8 years ago

thanks. My problem, MAMP is running without Apache.

divesh
divesh
8 years ago
Reply to  Ryota Bannai

I am having problem plz help me out

Ryota Bannai
Ryota Bannai
8 years ago
Reply to  divesh

what your problem like?

Anonymous
Anonymous
6 years ago

Thank you very much , solved my problem

Alex Smirnov
6 years ago
Reply to  Anonymous

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

rohullah
rohullah
3 years ago

thank you so much the easiest and best answer thanks alot

omar
omar
3 years ago

it works, thanks

lampard
lampard
12 years ago

thank you so much

Guest
Guest
12 years ago

Greatest tutorial very very helpful

Guest
Guest
12 years ago

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?

Guest
Guest
11 years ago

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

Thanks,

Prasadi
Prasadi
11 years ago

thank you so so so much!

Deelux
Deelux
11 years ago

You are AWESOME…! This worked like a charm! Thanks so much for taking the time to make this guide!

Bill T
Bill T
11 years ago

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
mikail
11 years ago

I was searching for this answer whole my live,thanks

Pratik Goyal
Pratik Goyal
11 years ago

You’re truly a superstar… i liked the way you explained… easy steps…saved my time..hats off!

Craiger
Craiger
11 years ago

Thank you so much! Worked perfectly for me.

chemic
chemic
11 years ago

pretty nice solution..#thx 😀

vinod chauhan
vinod chauhan
11 years ago

there is still an error in using it .. i have dne all thiss,pls help me out

ravi
ravi
11 years ago

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
Santos
11 years ago

Thank you very much!! Perfect!!!

myavila
myavila
11 years ago

Thank you very much for this useful information. It really helped.

Ruthine
Ruthine
11 years ago

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
FAISAL
11 years ago

GREAT SIR,,,ITS USEFULLL

D
D
11 years ago

Absolutely amazing! Thanks so much!

Nadeesha
Nadeesha
11 years ago

Thank You very much for this useful information…

Sheela
Sheela
11 years ago

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

Zac Ang
Zac Ang
9 years ago
Reply to  Sheela

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.

arshad nawaz
arshad nawaz
11 years ago

thanks,great work

davidah
davidah
11 years ago

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
gaps
11 years ago

You saved me my man. Thank you so much

frederick
frederick
11 years ago

Thanks man. You are indeed good at what you do. thank you once again. you are the man.

Leslie Luke
Leslie Luke
11 years ago

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

Emmezali
Emmezali
4 years ago
Reply to  Leslie Luke

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:

Leslie Luke
Leslie Luke
11 years ago

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
mohid
11 years ago

work fine in my wamp sever. but log in page not show when start first. please any one help me? thanks lot.

Antonio Lacruz
Antonio Lacruz
11 years ago

Thank you a thousand times!

Ugo
Ugo
11 years ago

Done! Thank you very much. You solve this problem

Vaishnavi
Vaishnavi
11 years ago

Awesome… Thank u very much. It worked for me and saved a big trouble.

Ketan Sawant
Ketan Sawant
11 years ago

It is really very valuable

Done!

Thanks

Vikas Sharma
Vikas Sharma
11 years ago

Error is same but it’s showing (using password: no)

and this solution is not working.

Is there any other solution?

jasonb
jasonb
11 years ago

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

SanVar
SanVar
11 years ago

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

Karthick manoharan
Karthick manoharan
11 years ago

no still i done all the changes its not happening ..still acces denied only im getting

w.izzy
w.izzy
11 years ago

you rule indeed

abc
abc
11 years ago

The additional features for working with linked tables have been deactivated. how to solve this problem

Thanks
Thanks
11 years ago

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)

coolman88
coolman88
11 years ago

For anyone who still gets the same error message screen after applying above steps, trying clearing your web browser cache.

Anas Ashraf
Anas Ashraf
11 years ago

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..

tired_as_a_runaway_slave
tired_as_a_runaway_slave
10 years ago

Many thanks great help Tessa …

hems
hems
10 years ago

Thank you! This works

Brandon
Brandon
10 years ago

I followed all of your steps but get this when entering https://localhost/phpMyAdmin/ into my browser: ‘This webpage is not available’

Soukaina Ouhame
Soukaina Ouhame
10 years ago

thanks it works 🙂

john
john
10 years ago

#1273 how to solve it

wow2tharu
wow2tharu
10 years ago

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.. 🙂

Varun
Varun
10 years ago

mind blowing ! 😀

142
0
Would love your thoughts, please comment.x
()
x