MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)

mysql -u root error 1045 (28000): access denied for user 'root'@'localhost' (using password: no)
error 1045 (28000): access denied for user 'cacti'@'localhost' (using password: yes)
rds mysql error 1045 (28000): access denied for user
mysql access denied for user
error 1045 (28000): access denied for user 'root 172.18 0.1 using password: yes
error 1045 28000 access denied for user shubh localhost using password no
error 1045 (28000): access denied for user zabbixuser localhost' (using password: yes)
error 1045 (28000): access denied for user 'ambari'@'localhost' (using password: yes)

First let me mention that I've gone through many suggested questions and found no relevent answer. Here is what I'm doing.

I'm connected to my Amazon EC2 instance. I can login with MySQL root with this command:

mysql -u root -p

Then I created a new user bill with host %

CREATE USER 'bill'@'%' IDENTIFIED BY 'passpass';

Granted all the privileges to user bill:

grant all privileges on *.* to 'bill'@'%' with grant option;

Then I exit from root user and try to login with bill:

mysql -u bill -p

entered the correct password and got this error:

ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)

Fixing MySQL 1045 Error: Access Denied, a 1045 error". So let's take a look at why the MySQL 1045 error Access Denied triggers. ERROR 1045 (28000): Access denied for user  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) But in my case, the cause was really silly. I copied the command from a Word document, and the problem was that an hyphen did not have the ASCII 2D code but the Unicode E28093.

Try:

~$ mysql -u root -p
Enter Password:

mysql> grant all privileges on *.* to bill@localhost identified by 'pass' with grant option;

MySQL - ERROR 1045 (28000): Access denied for user, The reason you could not login as repl@'%' has to do with MySQL's user authentication protocol. It does not cover patterns of users as one would believe. MySQL Error: : 'Access denied for user 'root'@'localhost' Hot Network Questions If someone can sing a melody, why can they not also recognize the intervals within that melody?

When you ran

mysql -u bill -p

and got this error

ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)

mysqld is expecting you to connect as bill@localhost

Try creating bill@localhost

CREATE USER bill@localhost IDENTIFIED BY 'passpass';
grant all privileges on *.* to bill@localhost with grant option;

If you want to connect remotely, you must specify either the DNS name, the public IP, or 127.0.0.1 using TCP/IP:

mysql -u bill -p -hmydb@mydomain.com
mysql -u bill -p -h10.1.2.30
mysql -u bill -p -h127.0.0.1 --protocol=TCP

Once you login, please run this

SELECT USER(),CURRENT_USER();

USER() reports how you attempted to authenticate in MySQL

CURRENT_USER() reports how you were allowed to authenticate in MySQL from the mysql.user table

This will give you a better view of how and why you were allowed to login to mysql. Why is this view important to know? It has to do with the user authentication ordering protocol.

Here is an example: I will create an anonymous user on my desktop MySQL

mysql> select user,host from mysql.user;
+---------+-----------+
| user    | host      |
+---------+-----------+
| lwdba   | %         |
| mywife  | %         |
| lwdba   | 127.0.0.1 |
| root    | 127.0.0.1 |
| lwdba   | localhost |
| root    | localhost |
| vanilla | localhost |
+---------+-----------+
7 rows in set (0.00 sec)

mysql> grant all on *.* to x@'%';
Query OK, 0 rows affected (0.02 sec)

mysql> select user,host from mysql.user;
+---------+-----------+
| user    | host      |
+---------+-----------+
| lwdba   | %         |
| mywife  | %         |
| x       | %         |
| lwdba   | 127.0.0.1 |
| root    | 127.0.0.1 |
| lwdba   | localhost |
| root    | localhost |
| vanilla | localhost |
+---------+-----------+
8 rows in set (0.00 sec)

mysql> update mysql.user set user='' where user='x';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> select user,host from mysql.user;
+---------+-----------+
| user    | host      |
+---------+-----------+
|         | %         |
| lwdba   | %         |
| mywife  | %         |
| lwdba   | 127.0.0.1 |
| root    | 127.0.0.1 |
| lwdba   | localhost |
| root    | localhost |
| vanilla | localhost |
+---------+-----------+
8 rows in set (0.00 sec)

mysql>

OK watch me login as anonymous user:

C:\MySQL_5.5.12>mysql -urol -Dtest -h127.0.0.1 --protocol=TCP
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.5.12-log MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user(),current_user();
+---------------+----------------+
| user()        | current_user() |
+---------------+----------------+
| rol@localhost | @%             |
+---------------+----------------+
1 row in set (0.00 sec)

mysql>

Authentication ordering is very strict. It checks from the most specific to the least. I wrote about this authentiation style in the DBA StackExchange.

Don't forget to explicitly call for TCP as the protocol for mysql client when necessary.

MySQL ERROR 1045 (28000): Access denied for user 'root , Any attempt to access MySQL database will result in error: ERROR 1045 (28000​): Access denied for user 'root'@'ip-address' (using password:  C:\Program Files\MySQL\bin>mysql -u root mysql1. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) Notice: I don't have mysqld_safe or safe_mysqld files in MySQL version. Could you please help me? Below you can see the dump file generated by the command: C:\mysqld --init-file=C:\\mysql-init.txt

Super late to this

I tried all of these other answers and ran many different versions of mysql -u root -p but never just ran


mysql -u root -p

And just pressing [ENTER] for the password.


Once I did that it worked. Hope this helps someone.

[Solved] ERROR 1045 (28000): Access denied for user 'user'@'host , Error 1045: Access denied for user (using password: YES) in MySQL, [Solved] ERROR 1045 (28000): Access denied for user 'user'@'host'  not able to restrict the mysql AURORA access from a specific host.ERROR 1045 (28000): Access denied for user 'user'@'10.1.21.54' Hot Network Questions Why would frozen sausages defrost faster in water?

When you type mysql -u root -p , you're connecting to the mysql server over a local unix socket.

However the grant you gave, 'bill'@'%' only matches TCP/IP connections curiously enough.

If you want to grant access to the local unix socket, you need to grant privileges to 'bill'@'localhost' , which curiously enough is not the same as 'bill'@'127.0.0.1'

You could also connect using TCP/IP with the mysql command line client, as to match the privileges you already granted, e.g. run mysql -u root -p -h 192.168.1.123 or whichever local IP address your box have.

Solved: ERROR 1045 (28000): Access denied for user 'mahi , ERROR 1045 (28000): Access denied for user 'mahi'@'localhost' If the user "​mahi" does not have access to "mysql" database (Which is the  리눅스 셸에서 mysql을 실행하니 Access denied(접근 거부)가 나온다. [root@localhost ~]# mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) -p 옵션을 붙여 패스워드를 입력하자.

ERROR 1045 28000 Access denied for user 'root'@'localhost' using , Error MySQL ERROR 1045 (28000): Access denied for user When I connected to a remote MySQL, I encountered the MySQL database  MySQL ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES); Wampserver 3.2.0 new instalation or upgrading. Probably xamp using mariaDB as default is well. Wamp server comes with mariaDB and mysql, and instaling mariaDB as default on 3306 port and mysql on 3307, port sometimes 3308. Connect to mysql!

MySQL :: MySQL ERROR 1045 (28000): Access denied for user , Setup MySQL on Ubuntu Droplet getting error ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES). ERROR 1045 (28000): Access denied for user 'root'@'<hostname of windows 7>' (using password: YES). I already granted all the privileges to perfTester and root on MySQL server (windows 2003 server). Below is the output from windows 2003 server.

Setup MySQL on Ubuntu Droplet getting error ERROR 1045 (28000 , I have installed MariaDB on Ubuntu 16.04. But when trying for the first time is says: ~$ mysql ERROR 1045 (28000): Acces denied for user 'username'@  MySQL provides host based restriction for user access as a security features. In our production environment, we used to restrict the access request only to the Application servers.

Comments
  • Did you FLUSH PRIVILEGES?
  • Okay, I tried this without any success. Any other suggestion please.
  • What version of the server are you running? I've seen 5.1 behave oddly about this.
  • This happened to me while installing Magento and I made a much sillier mistake. Putting 'mysql -u magento -p magento' was prompting me for a password and instead of the default password I was putting the root password in.
  • @authentictech unfortunately, none of the suggested solutions worked for me at the time this question was posted. Please see my own answer that helped me getting outa this situation. That is the reason I did not mark any of them as the answer. Probably I can mark the highest ranked response as answer.
  • For anyone curious as to why 'bill'@'localhost' matches ''@'localhost' like I was, an empty string effectively acts a wild card in MySQL's authentication algorithm.
  • @Sanja Be extra careful with this workaround. You may be allowing anonymous access to your database from any location. In case of doubt, I would rather delete the user.
  • @RandomSeed Thank you for this comment! Probably I should just delete anonymous user. P.S. I found dev.mysql.com/doc/refman/5.1/en/default-privileges.html that says that these users surely can be deleted: DROP USER ''@'localhost';. They are not needed for some special purpose.
  • I dropped the anonymous user, but things still did not work. Then I found that I needed to issue also "FLUSH PRIVILEGES". It would be helpful to mention that also.
  • This is the answer! Why does this not come in bold capital letters in every mysql manual. DELETE THE ANONYMOUS USER OR IT WILL KILL ALL YOUR ATTEMPTS TO LOGIN FROM LOCALHOST!
  • This is rather dangerous, if someone hacks your bill@localhost mysql account, he will have infinite access to all the databases of your mysql server.