Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open MySQL database #12

Open
alexanderfefelov opened this issue Oct 18, 2020 · 4 comments
Open

Cannot open MySQL database #12

alexanderfefelov opened this issue Oct 18, 2020 · 4 comments

Comments

@alexanderfefelov
Copy link

Log:

time="2020-10-18T05:22:30+03:00" level=info msg="Fetched server coordinates: 55.866500, 38.443800"
time="2020-10-18T05:22:30+03:00" level=fatal msg="Cannot open MySQL database: default addr for network 'mysql-main-master.backpack.test' unknown"

Environment

Links

alexanderfefelov added a commit to alexanderfefelov/docker-backpack that referenced this issue Oct 18, 2020
@maddie
Copy link
Collaborator

maddie commented Nov 10, 2020

I'm not really sure about this issue, is this Docker specific?

@etfeet
Copy link

etfeet commented Feb 20, 2021

I'm getting this issue as well

Environment:
OS: Ubuntu 18.04 lts virtual machine
go version: 1.14.2 linux/amd64
kernel: 4.15.0-135-generic

ive tried using the hostname as well as the ip address (with and without mysql port included) . and both result in the following error:
INFO[0000] Fetched server coordinates: 32.715700, -117.164700
FATA[0000] Cannot open MySQL database: default addr for network 'my-dns-hostname' unknown

database_hostname="my-dns-host"
database_hostname="my-dns-host:3306"
database_hostname="127.0.0.1"
database_hostname="127.0.0.1:3306"
database_hostname="localhost"
database_hostname="localhost:3306"

All of the above produce the same connection error on startup. It seems like its failing to resolve dns. However, the os itself is able to do it just fine...

I've also tried adding a host file entry for ip dns record in /etc/hosts. However, it still produces the same error.

@BeanLiu1994
Copy link

BeanLiu1994 commented Mar 8, 2021

in https://github.com/go-sql-driver/mysql#examples
connection string is set as following:

id:password@tcp(your-amazonaws-uri.com:3306)/dbname

so database_hostname should be set in this format :

database_hostname="tcp(your-amazonaws-uri.com:3306)"

@yas-nyan
Copy link
Contributor

FYI, I found that by writing the configuration file as shown below, everything works without any problems.

database_type="mysql"
database_hostname="tcp(127.0.0.1:3306)"
database_name="speedtest"
database_username="speedtest"
database_password="EXAMPLEPASSWORD"

We may need to add this "MySQL-specific configuration" to the README, or rewrite the code for connecting to MySQL as follows. (Of course, this is a dirty example.)

connectionStringTemplate = `%s:%s@%s/%s?parseTime=true`

// connectionStringTemplate = `%s:%s@%s/%s?parseTime=true`
connectionStringTemplate = `%s:%s@tcp(%s:3306)/%s?parseTime=true`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants