Cannot log into phpMyAdmin on Ubuntu 18.04


I used Alibaba Cloud Ubuntu 18.04 64



I solved it
The correct way is to login to my-sql with sudo privilege.

$ sudo mysql -u root -p

And then updating the password using:

$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';

Once this is done stop and start the mysql server.

$  sudo service mysql stop
$  sudo service mysql start


In Ubuntu 18.04 the version of MySQL that gets installed is designed so that the “root” user cannot log into phpMyAdmin as a default security measure. This is because everything comes with a “root” username and therefore it’s one less thing for a hacker to guess when breaking into your system.

In terms of security best practices, you should create a new user that has root privileges. Something obscure that also can’t be guessed. Thus making it substantially more difficult for attackers to access your system.

The instructions for the recommended method have been documented in this post: Cannot log into phpMyAdmin as root user

1 Like