Cannot log into phpMyAdmin on Ubuntu 18.04

I used Alibaba Cloud Ubuntu 18.04 64

I solved it
Solution:
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

2 Likes

Hi Craig,

Just wanted to say thank you for this. I have been struggling with this for a few weekends. I see you posted this in Apr, but you support for magento2 is really helping me now in Oct’19.

Cheers

Paul

1 Like