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
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
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
<span class="token function">sudo</span> mysql -p -u root
CREATE USER 'pmauser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password_here';
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost';