Categories

ID #1321

I've forgotten my MySQL root password. How do I get it back?

Forgotten root mysql password

 

I've forgotten my MySQL root password. How do I get it back?

 

Getting the MySQL root password back is hard (sha-1 hash).

 

Resetting the password is probably wiser.

 

To do a reset of the password, stop all applications that use the MySQL service during the reset operation. Stop the mysql service and start it in safe mode during the reset.

The following commands on the head node (tested for CentOS 7) show how such a reset session can be carried out:

# systemctl stop mariadb.service  
# mysqld_safe --skip-grant-tables &
# mysql -u root
MariaDB [(none)]> use mysql;
MariaDB [(none)]> update user set password=PASSWORD("newpass") where
User='root';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit
 
# pkill mysqld_safe
# systemctl start mariadb.service

Tags: -

Related entries:

You cannot comment on this entry