Table of Contents
In some cases, when you login into phpMyAdmin, you get the following error:
Can’t log into phpMyAdmin: mysqli_real_connect(): (HY000/1698): Access denied for user ‘root’@’localhost’.
This error may be due to one of the following reasons:
- Due to changes in MySQL 5.7 / MySQL 8+, you cannot log into phpMyAdmin using the root account.
- You have forgotten your root password.
Create a New Superuser for phpMyAdmin
1. In terminal, log in to MySQL as root. You may have created a root password when you installed MySQL for the first time, or the password could be blank. If you have forgotten your root password, you can always Reset the MySQL Root Password.
sudo mysql -p -u root
2. Now add a new MySQL user with the username of your choice. In this example we are calling it pmauser. Make sure to replace password_here with your own.
The command below will create a new user called pmauser (call this what you like) which can access the MySQL server from localhost with the password password_here.
CREATE USER 'pmauser'@'localhost' IDENTIFIED BY 'password_here';
3. Now we will grant superuser privilege to our new user pmauser.
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost' WITH GRANT OPTION;
###The output MariaDB [(none)]> CREATE USER 'pmauser'@'localhost' IDENTIFIED BY 'xxxxxxxxxxxx'; Query OK, 0 rows affected (0.002 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost' WITH GRANT OPTION; Query OK, 0 rows affected (0.001 sec)
You should now be able to access phpMyAdmin using this new user account.