I have already checked the other Stack Overflow and web links on this:
MySQL is on a Linux server
Linux uslx600 2.6.32-358.14.1.el6.x86_64 #1 SMP Mon
Says its IP is 1.2.3.4
I can connect to it from my laptop using MySQL Workbench. I cannot attach image due to Stack Overflow policy, but the dialog is as follows:
Connection Method: tcp/ip
Hostname: <host of the server, so e.g. 1.2.3.4>
Port: 3306 <This is same port as mentioned below for JDBC connection>
username: bugs
Default Schema: bugs
Within that mysql I ran [select user(), current_user()]
, I get
- user() =
bugs@<my laptop IP>
- current_user() =
bugs@%
Now I am trying to connect from the Linux server where the MySQL database is.
Following works, user is user by itself, i.e. no "@%" or something:
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bugs", user, pasword);
Following also works:
conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/bugs", user, pasword);
But it does not work, if I give the IP address of the box or hostname. And what I am really working towards is accessing this from another Linux server, which does not work either probably due to same issue.
The error message when it fails is:
Access Denied for user 'bugs'@'<hostname of the server>' (using password=YES)
If there was some access issue on the server, shouldn't the MySQL Workbench have the same issue?
And current_user()
says bug@%
so does it not imply that user is setup correctly?
I have also tried changing user to 'user'@'%' etc., but in all those cases error message was always:
'bugs'@'%'@'<hostname>'