Skip to content
Advertisement

Access denied for user ‘root’@’localhost’ after installing phpmyadmin on ubuntu

I installed phpmyadmin on my ubuntu server following these steps here:

https://www.rosehosting.com/blog/install-phpmyadmin-on-ubuntu-16-04/

I installed apache, php, mysql following these steps:

https://vijayasankarn.wordpress.com/2017/01/17/setting-lamp-stack-in-ubuntu-16-04-using-aws-ec2/

and when I goto login to http://myserver.com/phpmyadmin I get this error:

mysqli_real_connect(): (HY000/1045): Access denied for user ‘root’@’localhost’ (using password: YES)

What am I doing wrong? Am I missing a step that is not in the links above?

I have tried this:

mysql> USE mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

and this

mysql -u root -p
use mysql;
update user set plugin="" where user='root';
flush privilege;

Advertisement

Answer

This error can be fixed, the following command will reconfigure your phpMyAdmin credentials to gain access to the MYSQL DB:

sudo dpkg-reconfigure phpmyadmin

/! This will provide few interactive menus that will allow you to reconfigure the phpMyAdmin package with NEW credentials /!

But you could also reconfigure it manually :

1 – Log into mysql as root

mysql -u root -p

2 – Make sure ‘phpmyadmin’ user exists :

SELECT User FROM mysql.user;

3 – Switch to the appropriate MYSQL DB :

use phpmyadmin;

4 – Set new password for the phpmyadmin user

UPDATE user SET password=PASSWORD('yourNewPassword') WHERE User='phpmyadmin';
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement