MySQL – Unable to login with password, but without password its working

loginsMySQLSecurityusers

I have a master-slave setup, Slave is not in read only mode.(we can do all writes).
I have created a user.

create user 'bhuvi'@'%' identified by 'bhuvi';
grant all privileges on *.* to 'bhuvi'@'localhost';
flush privileges;

But when I try to login, its showing

[root@1user]# mysql -u bhuvi -p
Enter password:
ERROR 1045 (28000): Access denied for user 'bhuvi'@'localhost' (using password: YES)
[root@1user]#

But I can able to login with -p

mysql -u bhuvi

I don't why its happening.
AndI tried to create users like `'user'@'localhost, this is working, But I don't know why the user has '%' is not working.

(Im trying access the user login on the same server where the MySQL is installed)

Best Answer

network mask - is part of user name in MySQL

  1. create user 'bhuvi'@'%' identified by 'bhuvi'; - You are create user with password
  2. grant all privileges on . to 'bhuvi'@'localhost'; - You create 2nd user without password

enter image description here

1st have password, but not privileges

2nd have all privileges, but not password