Outils pour utilisateurs

Outils du site


informatique:how_to_reset_your_mariadb_root_password

Comment Réinitailiser le mot de passe Admin MariaDB

 

Did you forget your MariaDB root password? Do not worry, there is an easy way to reset your password in less than 5 minutes. This article will walk you through resetting your MariaDB root password on your Linux server. Please note that you need to have root access to your server to be able to change the password.

– Log in to your Linux virtual server via SSH as user root and stop the running MariaDB daemon:

# service mysql stop
Shutting down MySQL. SUCCESS!

– Start MariaDB in safe mode with ‘skip-grant-tables’ option. Grant tables store the passwords, so using this option you can login to MariaDB without password:

# mysqld_safe --skip-grant-tables &
[1] 14721
131108 19:06:41 mysqld_safe Logging to '/var/lib/mysql/domain.com.err'.
131108 19:06:41 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Now, you are able to log in to MariaDB without a password:

# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.33a-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.
MariaDB >

Once you are logged in, you can reset your MariaDB root password by executing the following SQL commands:

MariaDB [(none)]> use mysql;
MariaDB [(none)]> update user set password=PASSWORD("NEWPASSWORD") where User='root';

Don’t forget to replace ‘NEWPASSWORD’ with your actual password.

Now, flush the privileges and exit from the MariaDB server:

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

Finally, restart your MariaDB server:

# service mysql restart

Done. You old MariaDB root password is changed and you have a new password.

Now you can log in to MariaDB using the new password:

# mysql -u root -p

Of course, if you are one of our Linux VPS Hosting customers, you don’t have to do any of this, simply ask our admins, sit back and relax. Our admins will set this up for you immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

informatique/how_to_reset_your_mariadb_root_password.txt · Dernière modification : 2022/04/10 17:12 de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki