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

System Architect | MCSE: Core Infrastructure

An IT infrastructure expert with over 15 years of hands-on experience. Currently serving as a Systems and Network Project Manager and Information Systems Security (ISS) Lead, I leverage my expertise to ensure the reliability and security of technological environments.

GHinM▶