Set root password

I will explain how to set the root password.

The root password is not set in the initial state of MariaDB. Follow the steps below to set the root password.

If not set, anyone can perform all operations on the database, which poses a high security risk.

First, as the root user, connect to the MariaDB database without a password.

mysql -uroot

Change the database to "mysql".

use mysql

Set root password

Set the root password.

update user set Password = password ('ghrudifA! &') Where User ='root';
flush privileges;

If you forget your root password

If you have forgotten your root password, follow these steps:

Difference between MySQL and MariaDB root password settings

Since MySQL 5.7.6, root password setting seems to be done using the authentication_string field instead of the Password field.

In MariaDB 10.1.44, which I tried on June 17, 2020, there was a Password field and I was able to set it.

Associated Information