reset mysql root password
Posted: Wed Jul 30, 2025 4:19 pm
stop mysqld
edit mysqld conf
append to the conf
restart mysqld
Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables:
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
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.
Code: Select all
systemctl stop mysqldCode: Select all
sudo nano /etc/mysql/my.cnfCode: Select all
[mysqld]
# For debugging and recovery only #
skip-grant-tables
skip-networkingCode: Select all
sudo systemctl start mysqldCode: Select all
$> mysqlCode: Select all
mysql> FLUSH PRIVILEGES;Code: Select all
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';