
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:
1 2 |
<strong>[root@Unixmen-test ~]# service mysql stop</strong> <strong> Shutting down MySQL. SUCCESS!</strong> |
Start MySQL Daemon in Safe Mode:
1 2 3 4 5 |
<strong>[root@Unixmen-test ~]# mysqld_safe --skip-grant-tables &</strong> <strong> [1] 20224</strong> <strong> [root@Unixmen-test ~]# 130805 10:43:05 mysqld_safe Logging to '/var/lib/mysql/Unixmen-test.kimsufi.com.err'.</strong> <strong> 130805 10:43:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql</strong> |
Login to MariaDb server without a password:
1 2 3 4 5 6 7 8 9 |
<strong>[root@Unixmen-test ~]# mysql -u root</strong> <strong> Welcome to the MariaDB monitor. Commands end with ; or \g.</strong> <strong> Your MariaDB connection id is 1</strong> <strong> 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.</strong> |
Set the new password in the line below:
1 2 3 |
<strong>MariaDB [(none)]> update mysql.user set password=PASSWORD("newpassword") where User='root';</strong> <strong> Query OK, 4 rows affected (0.00 sec)</strong> <strong> Rows matched: 4 Changed: 4 Warnings: 0</strong> |
Flush privileges on exit:
1 2 3 4 5 |
<strong>MariaDB [(none)]> flush privileges;</strong> <strong> Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit;</strong> <strong> Bye</strong> |
Restart MySQL daemon:
1 2 3 4 5 |
<strong>[root@Unixmen-test ~]# service mysql restart</strong> <strong> Shutting down MySQL..130805 10:44:16 mysqld_safe mysqld from pid file /var/lib/mysql/Unixmen-test.kimsufi.com.pid ended</strong> <strong> SUCCESS!</strong> <strong> Starting MySQL.. SUCCESS!</strong> <strong> [1]+ Done mysqld_safe --skip-grant-tables</strong> |
Login now to check the new password:
1 2 3 4 5 6 7 8 9 10 |
<strong>[root@Unixmen-test ~]# mysql -u root -p</strong> <strong> Enter password:</strong> <strong> Welcome to the MariaDB monitor. Commands end with ; or \g.</strong> <strong> Your MariaDB connection id is 1</strong> <strong> 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.</strong> |
Show the tables or databases:
1 2 3 4 5 6 7 8 9 10 11 12 |
<strong>MariaDB [(none)]> show databases;</strong> <strong> +--------------------+</strong> <strong> | Database |</strong> <strong> +--------------------+</strong> <strong> | information_schema |</strong> <strong> | mysql |</strong> <strong> | performance_schema |</strong> <strong> | test |</strong> <strong> +--------------------+</strong> <strong> 4 rows in set (0.00 sec) MariaDB [(none)]></strong> |
Done!
Souce:https://www.unixmen.com/reset-mariadb-root-password/
未经允许不得转载:VPS啦 » Reset MariaDB Root Password in CentOS 6.4