Background
After installing a new server, or doing a server migration, you find you can’t suddenly can’t log into PHPMyAdmin as root anymore.
The errors are:
Cannot log in to the MySQL server
and
mysqli_real_connect(): (HY000/1698): Access denied for user 'root'@'localhost'
In MySQL 5.7 (released Oct 2015) and MySQL 8, the root MySQL user is set to authenticate using the auth_socket
or caching_sha2_password
plugin rather than with mysql_native_password
. This will prevent programs like phpMyAdmin from logging in with the root account.
Create a New Superuser for phpMyAdmin
First
sudo mysql -p -u root
then
CREATE USER 'pmauser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password_here';
then
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost';
Reference