1

I used

grant all on mydb.* TO user1@"localhost" identified by "user1"

And getting following error when access the mysql from a separate physical box.

This is a mysql cluster(Mysql server version 5.1.56). And connector jar is mysql-connector-java-5.1.26.jar.

Any ideas?

Caused by: java.sql.SQLException: Access denied for user 'user1'@'166.31.44.23' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078) ...

Bohemian
  • 412,405
  • 93
  • 575
  • 722
Subash Chaturanga
  • 814
  • 2
  • 10
  • 20
  • 1
    Did you tell the server to reload the grant tables, i.e. with "FLUSH PRIVILEGES"? See [When Privilege Changes Take Effect](https://dev.mysql.com/doc/refman/5.6/en/privilege-changes.html) – VMai Jul 22 '14 at 22:26
  • 1
    Change your connection string to point to localhost, not to 166.31.44.23 – Alberto Gaona Jul 22 '14 at 22:30
  • ... or grant the rights to 'user1' or 'user1'@'166.31.44.23' ... and use the right password too (if needed). – VMai Jul 22 '14 at 22:43

1 Answers1

0

Unless the password is also "user1", you are using the grant syntax incorrectly: The identified by parameter is for the password (not the username).

Try this:

grant all on mydb.* TO 'user1'@'localhost' identified by 'mypassword'
Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • @VMai fair enough (remark removed). I wasn't sure only because I have never seen it coded with double quotes – Bohemian Jul 22 '14 at 22:41
  • I would consider the use of single quotes as good practice myself. The use of the username as password not ... And then there's the problem Alberto mentioned too. I didn't saw it before your edit of the question. – VMai Jul 22 '14 at 22:46