I have server1 and server2. On server1 I have a Go app, trying to connect to MySQL on server2.
Here are the IPs: server1 10.127.8.160; server2 10.127.8.161
I get the following error:
Error 1045: Access denied for user 'root'@'server1' (using password: NO)
This is the connection string i am using:
root:@(10.127.8.161:3306)/mydatabase
The password for root is empty string. I also tried 'root@' (without the column) with the same result. I don't think this is important, but I figured I should mention it.
This is what I have in server2. I have privileges for server1, but only by IP. The connection comes from server1 by hostname instead.
+------------------------------------------------------+
| Grants for root@10.127.8.160 |
+------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.127.8.160' |
+------------------------------------------------------+
The question is how do I make it connect using its IP not its hostname? I don't have much control over server2 to add more privileges.
And for completeness this are the privileges for hostname:
SHOW GRANTS FOR 'root'@'server1'
ERROR 1141 (42000) at line 1: There is no such grant defined for user 'root' on host 'server1'
Link to the driver: https://github.com/go-sql-driver/mysql
Thanks