phpmyadmin access denied for user ‘root’@’localhost’ (using password yes/no) – MySQL

phpmyadmin access denied for user ‘root’@’localhost’ (using password yes/no) – MySQL

Sometimes, you want to connect to mysql database using phpmyadin in linux. Then you may face errors is the “Access denied for user ‘root’@’localhost’ (using password yes/no) in PHPMyAdmin mysql linux” error. In this tutorial, you will learn how to fix phpmyadmin mysql access denied for user ‘root’@’localhost’ (using password no) in linux.

This is a very common issue whenever a user installs and configures a new PHPmyadmin in MySQL with linux ubuntu. Then the user has to face the problem, Which is Can’t log into phpMyAdmin: mysqli_real_connect(): (HY000/1698), (hy000/1045), HY000 3118 or HY000 4151: 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.

The “Access denied for user ‘root’@’localhost’ (using password yes/no)” error usually occurs when you are trying to log in to PHPMyAdmin MySQL with incorrect credentials or when the MySQL server is not configured correctly in linux ubuntu.

Here are some of the causes of access denied for user ‘root’@’localhost’ (using password no) error:

  1. Incorrect username or password: If you have entered incorrect login credentials, PHPMyAdmin will deny you access.
  2. Incorrect permission settings: Sometimes, the MySQL server may have incorrect permission settings, preventing you from accessing PHPMyAdmin.
  3. MySQL service not running: If the MySQL service is not running, you will not be able to access PHPMyAdmin.
  4. Incorrect MySQL configuration: If the MySQL server is not configured correctly, you will not be able to access PHPMyAdmin.

This mysqli::real_connect(): (HY000/1698), (hy000/1045), HY000 3118 or HY000 4151: 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 linux ubuntu. 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:

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

Access denied for user ‘root’@’localhost’ (using password yes)

By using the following steps, you can fix or resolve phpmyadmin mysql access denied for user ‘root’@’localhost’ (using password yes/no)” in Linux:

  • Step 1 – Login as Root user MySQL
  • Step 2 – Restart Apache Server
  • Step 3 – Test Root MySQL User For Access PHPMyadmin

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.

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 *