error 1045(28000):anonymous user problem I have removed anonymous users from mysql server but when one user trying to login from a specific host, current_user() still showing anonymous user. 

mysql&gt; select user,host from mysql.user\G  
*************************** 1. row ***************************  
user: a  
host: %  
*************************** 2. row ***************************  
user: root  
host: 127.0.0.1  
*************************** 3. row ***************************  
user: root  
host: ::1  
*************************** 4. row ***************************  
user: a  
host: hosta  
*************************** 5. row ***************************  
user: root  
host: hosta  
*************************** 7. row ***************************  
user: a  
host: localhost  
*************************** 8. row ***************************  
user: root  
host: localhost  
8 rows in set (0.00 sec)  


mysql&gt; show grants for 'a'@'hosta';  
+-------------------------------------------------------------------------------  
| Grants for a@hosta                                                                     
+-------------------------------------------------------------------------------  
| GRANT ALL PRIVILEGES ON *.* TO 'a'@'hosta' IDENTIFIED BY PASSWORD 'xxxxxxxx'  
+-------------------------------------------------------------------------------  
1 row in set (0.00 sec)  


When I am giving correct password i am unable to login  

mysql@hosta ==&gt; mysql -ua -p -S /tmp/mysql.sock -h hosta  
Enter password:  
ERROR 1045 (28000): Access denied for user 'a'@'hosta' (using password: YES)  


but when I am giving blank password, I am able to log in:

mysql@hosta ==&gt; mysql -ua -p -S /tmp/mysql.sock -h hosta  
Enter password:  

mysql&gt; select user(),current_user();  
+---------------------------------------+-----------------------+  
| user()                                | current_user()        |  
+---------------------------------------+-----------------------+  
| a@hosta                               | @hosta                |  
+---------------------------------------+-----------------------+  
1 row in set (0.00 sec)  


Any idea what I am missing here ?
Here is what you are missing


Connecting with user a via a socket is the same as connecting with user a via localhost.
Connecting with a socket will not use TCP/IP


If you are going to explicitly using a hostname, you must use TCP/IP with port 3306 and no socket

mysql -ua -p -h hosta --protocol=tcp -P3306


I have discussed using --protocol=tcp in my earlier posts


Jul 16, 2015 : mysql.sock not generated when starting MySQL server using XAMPP
Jul 13, 2015 : mysql restart issue after move database
Jul 11, 2013 : Rare error lasts only a second &quot;Can&#39;t connect to local MySQL server through socket &#39;/tmp/mysql.sock&#39; (146)&quot; 146=ECONNREFUSED
Mar 28, 2013 : MySQL - ERROR 1045 (28000): Access denied for user


You need to delete blank users, blank hosts, and blank passwords from mysql.user

DELETE FROM mysql.user WHERE user = '';
DELETE FROM mysql.user WHERE host = '';
DELETE FROM mysql.user WHERE password = '';
FLUSH PRIVILEGES;