Reset MariaDB Root Password in CentOS 6.4

I have forgot my MariaDB root password and when trying to reset the root password I was thinking, “Let Unixmen readers know how I have solved my issue”.

First, stop running MySQL daemon:

[root@Unixmen-test ~]# service mysql stop
 Shutting down MySQL. SUCCESS!

Start MySQL Daemon in Safe Mode:

[root@Unixmen-test ~]# mysqld_safe --skip-grant-tables &
 [1] 20224

[root@Unixmen-test ~]# 130805 10:43:05 mysqld_safe Logging to '/var/lib/mysql/Unixmen-test.kimsufi.com.err'.
 130805 10:43:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Login to MariaDb server without a password:

[root@Unixmen-test ~]# mysql -u root
 

Welcome to the MariaDB monitor. Commands end with ; or \g.
 Your MariaDB connection id is 1
 Server version: 5.5.32-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Set the  new password in the line below:

MariaDB [(none)]> update mysql.user set password=PASSWORD("newpassword") where User='root';
 Query OK, 4 rows affected (0.00 sec)
 Rows matched: 4 Changed: 4 Warnings: 0

Flush privileges on exit:

MariaDB [(none)]> flush privileges;
 Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit;
 Bye

Restart  MySQL daemon:

[root@Unixmen-test ~]# service mysql restart
 Shutting down MySQL..130805 10:44:16 mysqld_safe mysqld from pid file /var/lib/mysql/Unixmen-test.kimsufi.com.pid ended
 SUCCESS!
 Starting MySQL.. SUCCESS!
 [1]+ Done mysqld_safe --skip-grant-tables

Login now  to  check the new password:

[root@Unixmen-test ~]# mysql -u root -p
 Enter password:
 

Welcome to the MariaDB monitor. Commands end with ; or \g.
 Your MariaDB connection id is 1
 Server version: 5.5.32-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Show the tables or databases:

MariaDB [(none)]> show databases;
 +--------------------+
 | Database |
 +--------------------+
 | information_schema |
 | mysql |
 | performance_schema |
 | test |
 +--------------------+
 4 rows in set (0.00 sec)

MariaDB [(none)]>

Done!

 

 

Souce:https://www.unixmen.com/reset-mariadb-root-password/

阅读剩余
THE END