Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Error 1045, "Access denied for user 'user'@'localhost' (using password: YES)"

This question seem to be asked a lot however I cannot find a definitive answer.

I am making some webapp tests using MySQL, and at the beginning I used the 'root' user (with a non-empty password). My root user is working fine from the apps (tested from PHP and Python's Django), from the command line, and with PHPMyAdmin.

However I don't wanted to use the the root user, so I created another user, and I granted all privileges to the databases that user should need. (I used PHPMyAdmin logged as 'root' for this task).

The new user cannot log in to MySQL. Neither from the Django app, nor PHPMyAdmin, nor the command line.

I have two possible suspicions:

  1. there is a global privilege the user lacks. (As I said, I granted all database privileges, however I have not granted any global privileges);

  2. the user's configured host. ('root' has four lines in the mysql.user table, for hosts 'localhost', 'my-pc-name', '127.0.0.1' and '::1'; while the new user has one line for host '%')

(I have double-checked the password, so I am confident this is not a password problem.)

like image 551
Carlos Eugenio Thompson Pinzón Avatar asked Apr 13 '13 14:04

Carlos Eugenio Thompson Pinzón


People also ask

How do I fix yes access denied for password?

To resolve the error, you must create a user with the following command: mysql> GRANT ALL ON *. * to user_name@localhost IDENTIFIED BY 'password'; Replace user_name with the user's username and password with the user's password.

How do I fix error 1045 in MySQL?

This is a solution, Error 1045 MySql Instalation. go to firewall from control panel, click on advanced setting in the left panel. Now, click on inbound rules. Add two mysql's under name one with Domain Profile the other with Private Profile.

How do I fix localhost Access Denied?

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.

How do I fix error 1045 28000 Access denied?

How to fix “Error 1045 (28000) access denied for user 'root'@'localhost' (using password: yes)”? It arises when you perform a fresh installation of MySQL and try to login with a password. The default password of MySQL is blank () (i.e. empty string). So, you can login to the MySQL server using the same password.


1 Answers

% means that the new user can access the database from any host.

However, if you supplied the CREATE USER statement would be much more useful.

In addition, check MySQL Manual below, where it explains why a user should have both @'localhost' and @'%':

MySQL Reference Manual - Adding Users

like image 52
johnnaras Avatar answered Oct 16 '22 21:10

johnnaras