Mysql: Cannot resolve network address with connection string

Created on 27 Feb 2016  ·  8Comments  ·  Source: go-sql-driver/mysql

Issue description

I've just started trying out Go, and I'm looking to re-implement an API server written in node with it.

I've hit a hurdle with the MySQL library that I can't seem to resolve. I'm trying to open a connection to an AWS RDS instance and have the connection string:

db, err := sql.Open("mysql", "username:[email protected]:3306/db_name")

With that I get this error:

default addr for network 'dbinstance.eu-west-1.rds.amazonaws.com:3306' unknown

I've tried wrapping the uri in a tcp(dbinstance.eu-west-1.rds.amazonaws.com:3306) inside the string, and then I get:

Error 1045: Access denied for user 'mysql'@'****.2-4.cable.virginm.net' (using password: YES) (the ** is some part of the network address I'm not putting on here)

Basically that's my cable provider - it looks like it's stopping at the first hop along the way.

If I change it to tcp(ipaddress) it seems to connect.

The node version of my app runs fine with the string connection

Configuration

*Driver version (or git SHA): Version 1.2

*Go version: go version go1.6 windows/amd64

*Server version: MySQL 5.6.23

*Server OS: Amazon RDS

Most helpful comment

db, err := sql.Open("mysql", "username:password@tcp(dbinstance.eu-west-1.rds.amazonaws.com:3306)/db_name") should be correct.

Error 1045: Access denied for user 'mysql'@'****.2-4.cable.virginm.net' (using password: YES) is a reply from the MySQL server. It looks like your username or password are wrong or the server does not accept connections from your IP. Does it work with the same credentials and from the same client with other libraries like the one for node or the offical c lib?

All 8 comments

db, err := sql.Open("mysql", "username:password@tcp(dbinstance.eu-west-1.rds.amazonaws.com:3306)/db_name") should be correct.

Error 1045: Access denied for user 'mysql'@'****.2-4.cable.virginm.net' (using password: YES) is a reply from the MySQL server. It looks like your username or password are wrong or the server does not accept connections from your IP. Does it work with the same credentials and from the same client with other libraries like the one for node or the offical c lib?

Nevermind, you already wrote that it works if you use the IP address instead of the domain.

The DSN also gets parsed fine: User:username Passwd:password Net:tcp Addr:dbinstance.eu-west-1.rds.amazonaws.com:3306 DBName:db_name.
I think the error must be on the server side. The driver seems to connect fine.

If the problem still exists, please reply

I'm not sure if this is the right place, but this is still an issue for me. I tried to connect with both the url and the ip address with the same result.

Error 1045: Access denied for user ''@'.fios.verizon.net' (using password: YES)

The driver is not the problem and the configuration of your URL_STRING is correct (with TCP protocol).

Example of correct configuration:

db, err := sql.Open("mysql", "username:password@tcp(dbinstance.eu-west-1.rds.amazonaws.com:3306)/db_name")

Maybe your problem is in the configuration of your database (mysql/mariadb). Attachment link to the reference of this problem: MYSQL ERROR 1045

I have had the same issue while connecting to RDS. adding tcp() in protocol did work. Thanks

just have to add net type, which means user:pass@net(url)/db

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BSick7 picture BSick7  ·  8Comments

tbdingqi picture tbdingqi  ·  7Comments

Dieterbe picture Dieterbe  ·  6Comments

AlekSi picture AlekSi  ·  3Comments

lunemec picture lunemec  ·  7Comments