MariaDB : Access denied for user 'root'@'localhost'

Just after installing MariaDB on Ubuntu / Debian, this error may appear if you try to connect with phpMyadmin.

To solve / work around the problem, we will create another user with the same level of rights as root.

1. Open an SSH connection on the server.

2. Enter the following commands:

mysql
CREATE USER 'admin'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;

3. Restart the MariaDB service.

It is now possible to connect with the admin user on phpMyadmin

Romain Drouche

Romain Drouche

Architecte Système | MCSE: Core Infrastructure

Expert en infrastructures IT avec plus de 15 ans d'expérience sur le terrain. Actuellement Chef de projet Systèmes et Réseaux et Référent SSI (Sécurité des Systèmes d'Information), je mets mon expertise au service de la fiabilité et de la sécurité des environnements technologiques.

GHinM▶