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 co
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
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..
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.
C:\xampp\mysql\bin\mysql.exe --user=root
USE mysql;
SELECT * FROM user \G;
UPDATE user SET password = PASSWORD('secret_pass') WHERE user = 'root';
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.
You can configure it with the "XAMPP Shell" (command prompt). Open the shell and execute this command:
mysqladmin.exe -u root password secret
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.
apt-get update
in the newly opened terminal.apt-get install
nano this will install nanocd ../opt/lampp/phpmyadmin
nano config.inc.php
and save.
Steps:
7 . now open your xampp dir ( c:/xampp ) --> 8 . to phpMyadmin dir [C:\xampp\phpMyAdmin]
10 .find [ $cfg['Servers'][$i]['auth_type'] = 'config';
]line and replace 'config' to ‘cookie’
$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 ]