Image

Knowledge base → Resetting the root password for the MariaDB server

[Virtual servers]
Date of publication: 17.10.2023

In this guide, we will describe resetting the password for the root user of the MariaDB database server. As an example, we will perform all actions on the Debian 12 operating system as root.

1. Preparation

1.1 Determine the server version

mysql --version

mysql Ver 15.1 Distrib 10.11.4-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper

1.2 Stopping the service

systemctl stop mariadb

1.3 Let's turn on the special mode

systemctl set-environment MYSQLD_OPTS="--skip-grant-tables --skip-networking"

1.4 Starting the service

systemctl start mariadb

2. Change password

Replace new_password with your new password.

mysql -u root

FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
UPDATE mysql.user SET authentication_string = '' WHERE user = 'root';
UPDATE mysql.user SET plugin = '' WHERE user = 'root';
exit;

3. Switch to normal mode

3.1 Remove the option from starting the service

systemctl unset-environment MYSQLD_OPTS

3.2 Restart the service

systemctl restart mariadb

3.3 Let's check the connection with the new password

mysql -u root -p




No Comments Yet