skip to Main Content

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;

3

Answers


  1. 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';
    
    Login or Signup to reply.
  2. sudo mysql -u root -p

    USE mysql;

    UPDATE user SET plugin=’mysql_native_password’ WHERE User =’root’;

    FLUSH PRIVILEGES;

    exit;

    sudo systemctl restart mysql

    Login or Signup to reply.
  3. Check to see that you have actually set the root password in MySQL. You might find that when logged in as the root Linux user you can run
    mysql -u root -p
    and get access to your database no matter which password you specify, because the password hasn’t actually been set. Use
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'PASSWORD'; FLUSH PRIVILEGES; EXIT;
    to set your password, then try phpMyAdmin again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search