Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

Reset MariaDB root password in Centos 8

If you lost the MariaDB root password on your centos 8 server, there is no need to worry about it. You can follow the below steps to reset mariadb password in centos 8.

On our server management plans, our experts will help you to reset the password without any data losses safely. You can check with our team at any time for emergency support.

At first you have to find the version of MariaDB by using following command

mysql --version

Then you should stop the currently running MariaDB server by:

systemctl stop mariadb

If you run MariaDB without loading information about the user privileges. This will allow you to access the database command line with the root privileges without providing the root password.

sudo mysqld_safe --skip-grant-tables --skip-networking &

Now you can able to access the MariaDB prompt with root privileges without using the password.1

mysql -u root

The most commonly using ALTER USER command to change root user password may not be supported in some versions of MariaDB. It’s because of grant tables are not loaded. We can reload the grant tables by issuing the following command.

MariaDB >  FLUSH PRIVILEGES;

If you are using newer MariaDB 10.1.20 and newer you can use the following command.

MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

For older version of MariaDB, you can use the following command.

SET PASSWORD FOR 'root'@'localhost' = PASSWORD ('new_password');

Make sure to replace the new_password with the strong one.

If the ALTER USER command doesn’t work , then you can try with the below command.

UPDATE mysql.user SET authentication_string = PASSWORD ('new_password') WHERE USER = 'root' AND HOST = 'localhost';

After this you should remember to reload the grant tables by using FLUSH PRIVILEGES command.

Then you have to kill the currently running mysql_safe PID.

netstat -tlnp | grep mysqld

Then you can find the PID of currently running MariaDB process.

kill -9 PID

Replace the PID with your PID of MariaDB process.

Then start the MariaDB by using the below command

systemctl start mariadb

MariaDB

mysql -u root -p

Prevent your websites from downtimes

Get our experts to provide 24×7 emergency support for crash recovery

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Can't get what you are looking for?

Available 24x7 for emergency support.