PHPMyAdmin Access Denied for user ‘root’@’localhost’ Ubuntu

PHPMyAdmin Access Denied for user ‘root’@’localhost’ Ubuntu

This is a very common issue whenever a user installs and configures a new MySQL. Then user has to face the problem, Which is Can’t log into phpMyAdmin: mysqli_real_connect(): (HY000/1698): Access denied for user ‘root’@’localhost’. This error message usually appears for new installations of MySQL when you try to login in PHPmyadmin with the root user.

But in this tutorial, you have been given a very easy solution. This will solve the problem “access denied for user ”@’localhost’ to database phpmyadmin'”.

This mysqli::real_connect(): (hy000/1045): access denied for user ‘root’@’localhost’ (using password: yes/no) tutorial guide will show you how to quickly resolve the access denied for user ‘root’@’localhost’ (using password yes) mysql phpmyadmin ubuntu 16/18/20.04. The outlined instructions apply to both MySQL and MariaDB. There will be no need to modify any tables or to perform complex configurations.

Prerequisites for access denied for user ‘root’@’localhost’ (using password yes) mysql phpmyadmin ubuntu 18.04/20.04 :

  • Access to a command line or terminal
  • MySQL or MariaDB installed
  • User with sudo or root privileges

Solve mysql_connect access denied for user ‘root’@’localhost’ (using password: yes/no)

Step 1 – Login as Root user MySQL

Installed MySQL and try to access phpmyadmin on the local/server machine with the root user, the command you use is:

mysql -u root -p

In most cases, you will receive the error message Access denied for user ‘root’@’localhost’.

You can enable access for root using one MySQL command.

To be able to log into MySQL as root, first use sudo to modify the root user:

sudo mysql

Enter your password at the prompt. A MySQL shell loads.

Use the ALTER USER command and change the authentication method to log into MySQL as root:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password';

This command changes the password for the user root and sets the authentication method to mysql_native_password. This is a traditional method for authentication, and it is not as secure as auth_plugin. In the example above, we set “root” as the password, but we encourage you to set a stronger password.

 mysql> FLUSH PRIVILEGES; 

Step 2 – Restart Apache Server

You need to restart Apache 2 server by using the following command:

sudo service apache2 restart

Step 3 – Test Root MySQL User For Access PHPMyadmin

Finally, you can login as root from phpMyAdmin. So, open your browser and type the below url with your ec2 server ip:

http://[SERVER_PUBLIC_IP]/phpmyadmin

Then you will look like on your browser:

Conclusion

In this tutorial, you have learned how to solve access denied for user ‘root’@’localhost’ (using password yes) mysql phpmyadmin ubuntu 18.04/20.04.

Recommended Linux/Ubuntu Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *