Table of Contents

,

mariadb reenable password authentication

Debian 10

Disable unix socket authentication

update mysql.user set plugin='' where user='root';
flush privileges;

Update password

update mysql.user set password=password('yourpasswd') where user='root';

or run mysql_secure_installation from command line and set password.

Check

select user,host,password,plugin from mysql.user;
MariaDB [(none)]> select user,host,password,plugin from mysql.user;
+------+-----------+-------------------------------------------+--------+
| user | host      | password                                  | plugin |
+------+-----------+-------------------------------------------+--------+
| root | localhost | *C3F43AFF2CF6AACD60EE1AAB1B48ADB3066E0EA4 |        |
+------+-----------+-------------------------------------------+--------+

Debian 11

This will disable unix socket authentication as well as set the password to 'root':

~# mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password USING PASSWORD ('root');"

Check

MariaDB [(NONE)]> SHOW CREATE USER root@localhost;
+---------------------------------------------------------------------------------------------------+
| CREATE USER FOR root@localhost                                                                    |
+---------------------------------------------------------------------------------------------------+
| CREATE USER `root`@`localhost` IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' |
+---------------------------------------------------------------------------------------------------+
1 ROW IN SET (0.001 sec)

Tested on

See also

References