home

How to change the ‘root’ password for MySQL in XAMPP?

January 3, 2009 · 42 comments

By default, when you install XAMPP in your windows machine, the ‘root’ password for the MySQL is set to empty. But this is not recommended, as the MySQL database without a password will be accessible to everyone. To avoid this, a proper/secure password must be set to the user ‘root‘. To do it in XAMPP, there are two ways.

Method 1: reset XAMPP MySQL root password through web interface:

After you started your XAMPP server, go to the browser and type the URL http://localhost/security/ (incase you’ve modified XAMPP server port, you need to include that port number also in previous URL). The security page will be shown where you can change the ‘root’ password for MySQL. This will update the phpMyAdmin config also.

Method 2: reset XAMPP MySQL root password through SQL update:

  1. Start the Apache Server and MySQL instances from the XAMPP control panel.
  2. After the server started, open any web browser and give http://localhost:8090/phpmyadmin/ (if you are running XAMPP on 8090 port). This will open the phpMyAdmin interface. Using this interface we can manager the MySQL server from the web browser.
  3. In the phpMyAdmin window, select SQL tab from the right panel. This will open the SQL tab where we can run the SQL queries.
  4. Now type the following query in the textarea and click Go
    UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
    FLUSH PRIVILEGES;
  5. Now you will see a message saying that the query has been executed successfully.
  6. If you refresh the page, you will be getting a error message. This is because the phpMyAdmin configuration file is not aware of our newly set root passoword. To do this we have to modify the phpMyAdmin config file.
  7. Open the file [XAMPP Installation Path] / phpmyadmin / config.inc.php in your favorite text editor.
  8. Search for the string $cfg['Servers'][$i]['password'] = ”; and change it to like this, $cfg['Servers'][$i]['password'] = ‘password’; Here the ‘password’ is what we set to the ‘root’ user using the SQL query.
  9. Now all set to go. Save the config.inc.php file and restart the XAMPP server.

Related Posts

{ 38 comments… read them below or add one }

Jonah Gibbons February 3, 2009 at 1:11 AM

bravo, thank you so much, this is the only tutorial i fond that actually somehow successfully worked my phpmyadmin client.

Reply

Maxi February 18, 2009 at 9:51 AM

Very nice Good job.

Reply

Dokuro March 18, 2009 at 6:53 AM

Tnx a lot

Reply

Marco April 16, 2009 at 10:00 AM

Thanx. Works well, but … is the “restart XAMPP” step at the end of the process really needed ?
In my case it didn’t.
Thanx again

Reply

Veerasundar April 16, 2009 at 4:43 PM

Hi Marco,

In my case, I had to restart XAMPP server, since I’d modified the phpMyAdmin config file and the server didn’t pickup the changes without restarting it.

Reply

random googler May 14, 2009 at 2:29 AM

Thanks

Reply

sss July 6, 2009 at 6:11 PM

thx vry much

Reply

Sravan July 7, 2009 at 2:43 PM

hi,

Really..Very Useful.Thx Dude..

Reply

qaiser August 16, 2009 at 5:56 PM

hi dear:i was using vertrigo with editor dreamweaver.all was working very well but when i installed xampp and joomla then all vertrigo stopped working and phpmyadmin did not opened and all databases that were made in mysql are not appearing.
plz help me as early as possible.

Reply

Veera August 16, 2009 at 8:44 PM

@qaiser

from your comment, I guess the problem might be because of port conflicts. If XAMPP and the other applications try to use same port, then these kind of problems may occur.

Please try changing XAMPP password and see if everything works fine.

Reply

????????? September 4, 2009 at 1:15 PM

Thank a lot.

Reply

Marco November 13, 2009 at 11:02 PM

Thanx. Works well, but … is the “restart XAMPP” step at the end of the process really needed ?
In my case it didn't.
Thanx again

Reply

sangram February 16, 2010 at 12:14 PM

Hi Veerasundar,

Thanks a lot

Reply

indra July 27, 2010 at 11:45 PM

Like this…

Reply

Spencer September 7, 2010 at 1:59 AM

Not sure what happened, but I got an error when I changed that info within the config file. I uninstalled XAMPP, and then reinstalled, and now I can’t access myPHPAdmin. I’m getting this error message: “#1045 – Access denied for user ‘root’@'localhost’ (using password: NO) ”

Do you know how to alleviate this?

Reply

Abdul Wahhab Qureshi September 21, 2010 at 1:28 PM

Very informative, thanx alot keep up the good work.

Reply

pratik October 16, 2010 at 8:10 PM

thank you very much it your tutorials helped me very much…but i am getting one problem i created other users on mysql with password…but when i tried to connect it through php using mysql_connect it says that can’t connect using password ‘YES’…plz help if u can…thanks..

Reply

Veera October 18, 2010 at 10:39 AM

I suspect that you are using wrong username/password combination. If you created a new username and password and you are trying to connect as this new user, then you have to use the newly created credentials.

Reply

Host Your Own Website At Home October 18, 2010 at 1:10 PM

Hi Veera

Thanks for this – its nice to see others working with XAMPP!

Here’s my take on securing XAMPP:

http://diyws.ath.cx/lessons/lesson-4-securing-xampp/

Cheers
Brad

Reply

kartonoiqbal October 25, 2010 at 11:10 AM

Thank you very much . Your post is very helpful for me fixing my problem

Reply

marcolo November 13, 2010 at 1:54 AM

really thanks :D

Reply

Benny W December 19, 2010 at 5:03 PM

Thanks mate that was a great help.

Reply

second hand December 26, 2010 at 8:48 PM

look good and helpful to me. thank you for your sharing

Reply

R. March 25, 2011 at 8:11 PM

The first part worked fine, but upon attempting to save the new password in the config.inc.php file, it refused to save, saying that I didn’t have privileges, or something to that effect. please help?

Reply

Jared April 13, 2011 at 2:25 AM

Excellent thanks.
BTW, where does XAMP store this config file to edit the MYSQL password manually?
Or is it an encrypted file that can only be modified via the web interface?
Jared

Reply

Mike July 2, 2011 at 2:58 AM

Ok, thanks!

Reply

shiva July 12, 2011 at 11:05 PM

thanku

Reply

mohd. tahir August 4, 2011 at 11:21 PM

thank you very much brother
it was very helpful

Reply

padmini August 11, 2011 at 3:05 PM

Thanks,all my problems solved..with small changes

Reply

mydexter September 9, 2011 at 1:58 PM

Thanks,all

Reply

rama September 15, 2011 at 2:13 PM

Dear sir,

Hi I want to know about the Nice menu and how to use this module in our website. Please describe with video if it is possible.

Reply

Veera September 16, 2011 at 5:36 AM

which menu are you talking about?

Reply

Anakha October 6, 2011 at 12:09 PM

Thank You!!!!

Reply

Pemuas Nafsu Dunia November 19, 2011 at 9:52 PM

i’ve search this anywhere, thx very much!!

Reply

sandhya January 6, 2012 at 4:37 PM

Thank you soo much.Easy way to finish the work.

Reply

sandhya January 6, 2012 at 4:38 PM

How to change the ‘root’ password for MySQL in XAMPP?

can you tell me how to change the user name also

Reply

programmer January 13, 2012 at 8:19 PM

+1 Great job. I look for so many website, could not fix it. This made it a piece of cake.

I had password set on mysql in xampp. My installation went corrupt and had to reinstall xampp. I left mysql as it is (as there were database I wanted to use). After installation, I could not login to phpmyadminbut my websites were working. Using method 1 above I changed the password and phpmyadmin is working now :) Thank you

Reply

movie January 21, 2012 at 11:44 PM

Thank you soo much Thank You!!!! Thank You!!!! Thank You!!!!

Reply

Leave a Comment

{ 4 trackbacks }

Previous post:

Next post: