So for the past hour I've been trying to figure out how to reset my 'root' password for MySQL as I cannot log into PHPMyAdmin. I've tried changing the password in the config.inc.php file and searching through other methods. I cannot find a successful way. A few months ago I changed it as a test password but now I forget what it was. If anyone can help, that would be great. (I'm running on a Windows computer).
15 Answers
You want to edit this file: "\xampp\phpMyAdmin\config.inc.php"
change this line:
$cfg['Servers'][$i]['password'] = 'WhateverPassword';
to whatever your password is. If you don't remember your password, then run this command within the Shell:
mysqladmin.exe -u root password WhateverPassword
where WhateverPassword is your new password.
-
7Safer to just put
mysqladmin -u root password
only (don't put the password in plain text on command line). The tool will ask you to type in the new password, and confirm it, and both instances will be masked:New password: ******** Confirm new password: ********
– ADTCJan 5, 2016 at 8:08 -
2WARNING: running the Shell command with 'WhateverPassword' will include the single quotes as part of your password. Don't include single quotes Apr 3, 2016 at 14:20
-
1
-
Steps:
- Open your phpMyadmin dashboard
- go to user accounts
- on the user section Get the root user and click [ Edit privileges ]
- in the top section you will find change password button [ click on it ]
- make a good pass and fill 2 pass field .
- now hit the Go button.
7 . now open your xampp dir ( c:/xampp ) --> 8 . to phpMyadmin dir [C:\xampp\phpMyAdmin]
- open [ config.inc.php ] file with any text editor
10 .find [ $cfg['Servers'][$i]['auth_type'] = 'config';
]line and replace 'config' to ‘cookie’
- go to [
$cfg['Servers'][$i]['AllowNoPassword'] = true;
] this line change‘true’ to ‘false’
.
last : save the file .
here is a video link in case you want to see it in Action [ click Here ]
-
11
-
hello OP you need to provide more info about your issue so i can counter the issue. if its asking for password or showing any error? if its showing any error the follow the 7,8,9,10,11 steps if not solved plz let me know. make a schreenshort of the issue and post it in replay– insCodeApr 8, 2016 at 21:11
-
You can configure it with the "XAMPP Shell" (command prompt). Open the shell and execute this command:
mysqladmin.exe -u root password secret
-
9Safer to just put
mysqladmin -u root password
only (don't put the password in plain text on command line). The tool will ask you to type in the new password, and confirm it, and both instances will be masked:New password: ******** Confirm new password: ********
– ADTCJan 5, 2016 at 8:08 -
If you're looking for mysqladmin.exe, for me on Windows 10, it was here C:\xampp\mysql\bin\mysqladmin.exe, so full command in shell/prompt should be as
C:\xampp\mysql\bin\mysqladmin.exe -u root password
(followed by Enter), then you will be asked to enter new password Jan 15, 2021 at 11:54
Follow the following steps:
- Open the XAMPP control panel and click on the shell and open the shell.
- In the shell run the following : mysql -h localhost -u root -p and press enter. It will as for a password, by default the password is blank so just press enter
- Then just run the following query SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword'); and press enter and your password is updated for root user on localhost
Reset XAMPP MySQL root password through SQL update phpmyadmin to work with it:
-Start the Apache Server and MySQL instances from the XAMPP control panel. After the server started, open any web browser and go to http://localhost/phpmyadmin/. This will open the phpMyAdmin interface. Using this interface we can manager the MySQL server from the web browser.
-In the phpMyAdmin window, select SQL tab from the right panel. This will open the SQL tab where we can run the SQL queries.
-Now type the following query in the textarea and click Go
"UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';"
hit go
"FLUSH PRIVILEGES;"
hit go
-Now you will see a message saying that the query has been executed successfully.
-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.
-Open the file C:\xampp\phpMyAdmin\config.inc.php in your favorite text editor. 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.
$cfg['Servers'][$i]['AllowNoPassword'] = false; // set to false for password required
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // web cookie auth
-Now all set to go. Save the config.inc.php file and restart the XAMPP server.
Modified from Source: http://veerasundar.com/blog/2009/01/how-to-change-the-root-password-for-mysql-in-xampp/
If you indeed forgot the root password to the MySQL server, you need to start it with the option skip-grant-tables
. Search for the appropriate Ini-File my.ini
(C:\ProgramData\MySQL Server ...
or something like this) and add skip-grant-tables
to the section [mysqld]
like so:
[mysqld]
skip-grant-tables
- Start the Apache Server and MySQL instances from the XAMPP control panel.
- Now goto to your localhost.
- Click on user accounts -> Click on Edit privileges -> You will find an option change password just change password as you want click on go. Image are given below
- 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.
- Open terminal window (not mac default terminal please check attached image)
- Then Run
apt-get update
in the newly opened terminal. - Then run
apt-get install
nano this will install nano - CD to
cd ../opt/lampp/phpmyadmin
- Open and Edit
nano config.inc.php
and save.
On xampp -> Phpmyadmin -> config.inc 21st line you see:
$cfg['Servers'][$i]['password'] = '';
Add your password here and restart your xampp. The password will change.
For me much better way is to do it using terminal rather then PhpMyAdmin UI.
The answer is copied from "https://gist.github.com/susanBuck/39d1a384779f3d596afb19fcad6b598c" which I have tried and it works always, try it out..
- Open C:\xampp\mysql\bin\my.ini (MySQL config file)
Find the line [mysqld] and right below it add skip-grant-tables. Example:
[mysqld] skip-grant-tables port= 3306 socket = "C:/xampp/mysql/mysql.sock" basedir = "C:/xampp/mysql" tmpdir = "C:/xampp/tmp" [...etc...]
This should allow you to access MySQL if you don't know your password.
- Stop and start MySQL from XAMPP to make this change take effect.
- Next, in command line, connect to MySQL:
C:\xampp\mysql\bin\mysql.exe --user=root
- Once in MySQL command line "select" the mysql database:
USE mysql;
- Then, the following command will list all your MySQL users:
SELECT * FROM user \G;
- You can scan through the rows to see what the root user's password is set to. There will be a few root users listed, with different hosts.
- To set root user's to have a password of your choice, run this command:
UPDATE user SET password = PASSWORD('secret_pass') WHERE user = 'root';
- -OR- To set all root user's to have a blank password, run this command:
UPDATE user SET password = '' WHERE user = 'root';
When you're done, run exit; to exit the MySQL command line.
Next, re-enable password checking by removing skip-grant-tables
from C:\xampp\mysql\bin\my.ini.
Save changes, restart MySQL from XAMPP.
1.-In XAMPP press button Shell
2.-place command:
mysqladmin -u root password
New password: aqui colocar password ejemplo ´09876´
3.-go on the local disk c: xampp \ phpMyAdmin open config.inic.php with notepad ++
5.- add the password and in AllowNoPassword change to false
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '09876';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['Lang'] = '';
6.- save changes, clear browser cache and restart xampp
-
2Please use English as your language - we don't have an automatic translation. To facilitate answering your question, please translate it into English and show, what you have done so far.– dmitryroMar 12, 2018 at 22:18
Try this:sudo /Applications/XAMPP/xamppfiles/xampp security Then follow the instructions
-
1
Open the file C:\xampp\phpMyAdmin\config.inc.php
in your text editor. Search for the tags below and edit accordingly
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Where 'password' is your new password. In-between quotes.
GO to your browser and visit link http://localhost/phpmyadmin/. Click on 'GO' without your new password. It would log you in and you would be able to see the "CHANGE PASSWORD". Proceed to change your password and you are done.
2020 Sep
launch xamp control panel
press admin in mysql row
in opened phpmyadmin press house icon on top left corner
in the top middle you will see user accounts tab and tap it
see in 'new' panel under the table to add a new user for your dbs and set access permissions
On Dashboard, Go to User Accounts, Select user, Click Change Password, Fill the New Password, Go.
SIMPLE STRAIGHT FORWARD WORKING SOLUTION AND OUT OF THE BOX:
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/phpmyadmin/. This will open the phpMyAdmin interface. Using this interface we can manage the MySQL server from the web browser.
3 - In the phpMyAdmin window, select SQL tab from the top panel. This will open the SQL tab where we can run the SQL queries.
4 - Now type the following query in the text area and click Go
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; FLUSH PRIVILEGES;
5 - Now you will see a message saying some thing like: 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 (e.g: C:\xampp\phpMyAdmin\config.inc.php
).
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 apache and mysql servers. It should work!
Source: https://veerasundar.com/blog/2009/01/how-to-change-the-root-password-for-mysql-in-xampp/
DONE!
-
You had previously answered this question. stackoverflow.com/a/39404200/5555803 Feb 18, 2018 at 4:19