How to reset your root password in MariaDB?

1. The first thing to do is to stop MariaDB server

$ sudo systemctl stop mariadb

2. Start MariaDB without asking for a password

$ sudo mysqld_safe --skip-grant-tables &

3. Connect from localhost to your server as root

 $ mysql -u root

4. Reload the grant tables

mysql> flush privileges;
Query OK, 0 rows affected (0.000 sec)

5. Change the root password for a new one

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Query OK, 0 rows affected (0.000 sec)

So the password has been changed.

6. Stop the manual instance of the database server

$ sudo kill `cat /var/run/mariadb/mariadb.pid`

7. Start MariaDb server

$ sudo systemctl start mariadb

Deja una respuesta