J33nn
J33nn

Reputation: 3234

MySql create user - can't connect using valid credentials

I'm trying to create new user in mysql and give him privileges to mess with one table.

Commands I've used:

CREATE USER 'integration'@'%' IDENTIFIED BY 'integration1';
GRANT SELECT, INSERT, ALTER, UPDATE, CREATE, DROP ON testdb.testtable TO 'integration'@'%';
FLUSH PRIVILEGES;

But unfortunately I can't connect to database using right credentials:

mysql.exe -uintegration -pintegration1 testdb

Upvotes: 0

Views: 199

Answers (2)

bazzilic
bazzilic

Reputation: 828

The thing is that MySQL has its specific way of handling the host from where connection originates. Generally localhost doesn't fall under '%'. Try connecting using this command:

mysql.exe -uintegration -pintegration1 -h127.0.0.1 testdb

This will initiate a connection from user 'integration'@'127.0.0.1' instead of 'integration'@'localhost'

Upvotes: 1

Cedric Simon
Cedric Simon

Reputation: 4659

If you connect locally, you must add the user @localhost.

CREATE USER 'integration'@'localhost' IDENTIFIED BY 'integration1';
GRANT SELECT, INSERT, ALTER, UPDATE, CREATE, DROP ON testdb.testtable TO 'integration'@'localhost';
FLUSH PRIVILEGES;

Upvotes: 1

Related Questions