Beego: Setting the Mysql Hostname

Created on 1 Dec 2014  路  3Comments  路  Source: astaxie/beego

Hi,
I'm having a problem connecting to a MySQL database.
Is it possible to specify the hostname for a MySQL connection, it currently defaults to 127.0.0.1
i.e I would like to use "localhost" instead.

[ORM]register db Ping `default`, dial tcp 127.0.0.1:3306: connection refused 

MySQL won't allow connections from 127.0.0.1 by default on Ubuntu :

[root@ip-10-190-106-52 stockz]# mysql -u root -p -h 127.0.0.1
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

[root@ip-10-190-106-52 stockz]# mysql -u root -p -h localhost
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.5.40-log MySQL Community Server (GPL)

Thanks

Most helpful comment

paddydub:
Look carefully at this documantaion
https://github.com/go-sql-driver/mysql

username:password@protocol(address)/dbname?param=value

mysql://user@unix(/path/to/socket)/pear
mysql://user:pass@tcp(localhost:3306)/pear

All 3 comments

I think you should open the issue in the mysql driver. beego don't know how to deal with this problem. it should be the driver's problem.

paddydub:
Look carefully at this documantaion
https://github.com/go-sql-driver/mysql

username:password@protocol(address)/dbname?param=value

mysql://user@unix(/path/to/socket)/pear
mysql://user:pass@tcp(localhost:3306)/pear

Have you opened your sql server on port 3306 ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drmaples picture drmaples  路  6Comments

kaushiksriram100 picture kaushiksriram100  路  3Comments

osavchenko picture osavchenko  路  4Comments

Jamlee picture Jamlee  路  5Comments

im-here picture im-here  路  4Comments