AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

MySQL/MariaDB: root password reset

PARTAGEZ

If you lose the MySQL or MariaDB root user password, you can reset it by restarting the service in secure mode, a mode that does not require a password.

MySQL: root password reset

The root password can be easily reset and changed directly from the terminal in just a few steps for MySQL.

Step 1: Stop the MySQL service

Start by stopping the database. Use the command appropriate for your system. In both cases, the sudo command is used to perform actions as root:

Managed databases

Managed and secure databases

  • Flexible solutions, tailored to your needs
  • Professional-grade architecture, managed by experts
  • Hosted in Europe, in accordance with the strictest data protection standards

Step 2: Start MySQL in Safe Mode

Then restart the database in secure mode to perform a reset from MySQL root password :

sudo mysqld --skip-grant-tables --skip-networking --pid-file=/tmp/mysqld-reset.pid &

You can now log in to MySQL as root without having to enter a password:

Step 3: Set a New MySQL Root Password

In the next step, you can choose a secure password using the following command:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Nouveau!Mot!De!Passe!Sécurisé';

Then load the privilege tables again:

Step 4: Restart MySQL in Normal Mode

Then exit the MySQL client with the following command:

Then stop MySQL:

mysqladmin -u root -p shutdown

Enter the root password you just set. Then restart the database in normal mode. Choose the appropriate command again for your system:

  • Ubuntu/Debian : sudo systemctl start mysql
  • CentOS/Red Hat : sudo systemctl start mysqld

MariaDB: root password reset

You can also change your root password on MariaDB in just a few steps. The process is very similar to MySQL.

Step 1: Stop the MariaDB service

First stop the database in MariaDB. To do this, you can use the following command:

sudo systemctl stop mariadb

Step 2: Start MariaDB in Safe Mode

To perform a MariaDB root password reset, you must now start the database in secure mode. To do this, execute the following command:

sudo mysqld_safe --skip-grant-tables --skip-networking --pid-file=/tmp/mariadb-reset.pid &

You can then log in as root to MariaDB. You no longer need a password for this:

Step 3: Set a new MariaDB root password

Finally, you can change your MariaDB root password to a new password of your choice. To do this, you can use the following command:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Nouveau!Mot!De!Passe!Sécurisé';

Reload the privilege tables:

Step 4: Restart MariaDB in Normal Mode

Exit the MariaDB client:

Then close MariaDB:

mysqladmin -u root -p shutdown

Then you can restart your database in normal mode:

sudo systemctl start mariadb

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact