MySQL -h option invalid

At first, we should comfirm we create a user, like this


use mysql;
select Host,User from user;

I get this error in Centos+Mysql 5.6

For convenient, I created a user: example_user@%, but I still can not login with mysql -u example_user -h 127.0.0.1 -p, the error message said Access denied for user ‘example_user’@localhost , I specificated the host as 127.0.0.1, why converted to localhost? And the “%” character should match all host.

After a lot of test, 127.0.0.1 is same as localhost, and % not match localhost in this version of MySQL, so, we just have to create a user in localhost.


grant all on example_db.* on "example_user"@"localhost" identified by "your password";
flush privileges;

Leave a Reply

Your email address will not be published. Required fields are marked *