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
System Architect | MCSE: Core Infrastructure
IT infrastructure expert with over 15 years of field experience. Currently a Systems and Networks Project Manager and Information Systems Security (ISS) expert, I use my expertise to ensure the reliability and security of technological environments.

Leave a Comment