How to reset Mariadb root password? Print

  • mariadb
  • 4

This tutorial mainly for CentOS server installed with Mariadb.

1) Stop mysql server

systemctl stop mysqld

2) Change environment option

systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3) Start mysql server and access without password

systemctl start mysqld
mysql -u root

4) Reset your mysql root password in MySQL command prompt. Replace NewPassword with your own password.

 UPDATE mysql.user SET authentication_string = PASSWORD('NewPassword') WHERE User = 'root';
 FLUSH PRIVILEGES;
 exit

5) Stop mysql server

systemctl stop mysqld

6) Remove environment option

systemctl unset-environment MYSQLD_OPTS

7) Restart mysql server

systemctl start mysqld

You should good to go.

 


Was this answer helpful?

« Back