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
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 ?
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