GENERIC MYSQL INFO
To start with, read the mysql manual: https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html
The steps will show you how to shutdown the service and start it with an overriding command that doesn't require passwords, then you reset the password. From the manual:
Stop the MySQL server, then restart it with the --skip-grant-tables
option. This enables anyone to connect without a password and with all privileges, and disables account-management statements such as ALTER USER
and SET PASSWORD
. Because this is insecure, you might want to use --skip-grant-tables
in conjunction with --skip-networking
to prevent remote clients from connecting.
Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables
:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'@'localhost'
account password. Replace the password with the password that you want to use. To change the password for a root account with a different host name part, modify the instructions to use that host name.
MySQL 5.7.6 and later:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
Or directly on the user table:
UPDATE mysql.user SET password=PASSWORD('mynewpassword') WHERE user='root';
XAMPP SPECIFIC
Stop the MySQL service. Open a command window. Change to the XAMPP MySQL directory:
> cd \xampp\mysql\bin\
Run the service without security (note you are running mysqld, not mysql):
> mysqld.exe --skip-grant-tables
The MySQL service will be running in this window, so open another command window and switch to the XAMPP MySQL directory:
> cd \xampp\mysql\bin\
Run the MySQL client:
> mysql
Update the password:
mysql> UPDATE mysql.user SET password=PASSWORD('mynewpassword') WHERE user='root';
Exit MySQL:
mysql> \q
Use task manager to cancel the mysqld.exe that is still running. Restart the mysql service.