reset mysql root password

Post Reply
zemerdon
Site Admin
Posts: 310
Joined: Mon Jan 23, 2023 8:13 pm

reset mysql root password

Post by zemerdon »

stop mysqld

Code: Select all

systemctl stop mysqld
edit mysqld conf

Code: Select all

sudo nano /etc/mysql/my.cnf
append to the conf

Code: Select all

[mysqld]
# For debugging and recovery only #
skip-grant-tables
skip-networking
restart mysqld

Code: Select all

sudo systemctl start mysqld
Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables:

Code: Select all

$> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:

Code: Select all

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.

Code: Select all

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Post Reply