远程Golang实例上的SQL数据库

时间:2016-03-07 15:52:03

标签: mysql amazon-web-services heroku go

我试图在Heroku上启动Go应用程序。这个应用程序使用相当大的SQL数据库;目前,数据库在我的本地,我称之为

db, err := sqlx.MustConnect("mysql", username+":"+password+"@tcp(localhost:3306)/"+environment)

在我的代码中。数据可从AWS桶中作为.sql文件访问。无论如何我可以让我的应用程序直接连接到这个sql文件,或者在localhost以外的地方托管数据库?

1 个答案:

答案 0 :(得分:0)

https://devcenter.heroku.com/articles/heroku-mysql

在heroku网站上,转到我的应用程序,然后选择已安装ClearDB的应用程序。

点击右上角的插件,然后选择 ClearDB MySQL数据库。 在那里,单击您的数据库并选择“端点信息”选项卡。在那里你看到你的用户名/密码。可以通过运行获取数据库的URL <{1}}在命令行中。

就我而言,它是这样的:mysql:// user:pass @ us-cdbr-east.cleardb.com / TABLE?reconnect = true 你需要的是这部分: us-cdbr-east.cleardb.com

PS: https://devcenter.heroku.com/articles/heroku-postgresql