Heroku上的设置数据库是什么?

时间:2022-09-15 17:49:59

I have deployed my Rails 3.1 app with the MySQL database to Heroku and there everything works fine. I mean, into database are saved the chars right (seems to be used UTF charset on a databases on Heroku).

我已经将我的Rails 3.1应用程序与MySQL数据库部署到Heroku,一切正常。我的意思是,在数据库中保存了正确的字符(似乎是在Heroku上的数据库上使用UTF字符集)。

But when I will run the command heroku db:pull (this command will download a whole database from Heroku into the database on localhost), so the downloaded data stored in databased have bad coding - a chars are displayed bad (it looks like my local MySQL database have a different set up of charset than the MySQL on Heorku).

但是当我运行命令heroku db:pull(这个命令会将整个数据库从Heroku下载到localhost上的数据库中)时,存储在数据库中的下载数据编码不好 - 字符显示不好(看起来像我的本地MySQL数据库与Heorku上的MySQL有不同的charset设置。

Could anyone give me a tip, how I can find the set up of charset used on Heroku database and how to use it on my local MySQL database?

任何人都可以给我一个提示,我如何找到在Heroku数据库上使用的charset的设置以及如何在我的本地MySQL数据库中使用它?

Many thanks!

非常感谢!

2 个解决方案

#1


4  

All is not lost - you really don't have to use PostgreSQL if you don't want to.

一切都没有丢失 - 如果你不想,你真的不必使用PostgreSQL。

If your database is small enough (which it will have to be since the Heroku PostGres DB is also 5Mb) and you would prefer to remain on mySQL then you could use the ClearDB mySQL addon - http://addons.heroku.com/cleardb - their entry level DB is free and is the same size as the Heroku Shared PostGres DB that you get by default but be careful that the number of connections is limited so don't be going crazy with your web dyno counts.

如果你的数据库足够小(因为Heroku PostGres数据库也是5Mb就必须这样),你宁愿继续使用mySQL,那么你可以使用ClearDB mySQL插件 - http://addons.heroku.com/cleardb - 他们的入门级数据库是免费的,并且与默认情况下获得的Heroku Shared PostGres数据库大小相同,但要注意连接数量是有限的,所以不要对你的web dyno计数感到疯狂。

Once you add the addon if you look at the output of heroku config then you can use the DATABASE_URL to create a connection in your favourite mySQL administration tool locally to restore/backup etc data to ClearDB. You may even find heroku db:push would work but personally I've not tried that so would be guessing.

如果查看heroku配置的输出,则添加插件后,可以使用DATABASE_URL在本地最喜欢的mySQL管理工具中创建连接,以将数据恢复/备份等数据到ClearDB。你甚至可能会发现heroku db:push会起作用,但我个人并没有尝试过,所以会猜测。

#2


2  

The problem is that Heroku does not use a MySQL database in production, but a PostgreSQL database.

问题是Heroku不会在生产中使用MySQL数据库,而是使用PostgreSQL数据库。

Therefore you will run into all sorts of issues pulling and pushing data from a different database engine. Taps is an activerecord based process that will reduce this problem but not all the time.

因此,您将遇到从不同的数据库引擎中提取和推送数据的各种问题。 Taps是一个基于活动记录的过程,可以减少这个问题,但不是所有时间。

Ideally you want to use PostgresSQL on your development machine (install via Homebrew for simplicity on OSX) and you'll not see any more of these problems.

理想情况下,您希望在开发计算机上使用PostgresSQL(通过Homebrew安装以简化OSX),您将不会再看到这些问题。

Alternatively, use one of the MySQL addons as described in the comments in the question.

或者,使用问题评论中描述的MySQL插件之一。

#1


4  

All is not lost - you really don't have to use PostgreSQL if you don't want to.

一切都没有丢失 - 如果你不想,你真的不必使用PostgreSQL。

If your database is small enough (which it will have to be since the Heroku PostGres DB is also 5Mb) and you would prefer to remain on mySQL then you could use the ClearDB mySQL addon - http://addons.heroku.com/cleardb - their entry level DB is free and is the same size as the Heroku Shared PostGres DB that you get by default but be careful that the number of connections is limited so don't be going crazy with your web dyno counts.

如果你的数据库足够小(因为Heroku PostGres数据库也是5Mb就必须这样),你宁愿继续使用mySQL,那么你可以使用ClearDB mySQL插件 - http://addons.heroku.com/cleardb - 他们的入门级数据库是免费的,并且与默认情况下获得的Heroku Shared PostGres数据库大小相同,但要注意连接数量是有限的,所以不要对你的web dyno计数感到疯狂。

Once you add the addon if you look at the output of heroku config then you can use the DATABASE_URL to create a connection in your favourite mySQL administration tool locally to restore/backup etc data to ClearDB. You may even find heroku db:push would work but personally I've not tried that so would be guessing.

如果查看heroku配置的输出,则添加插件后,可以使用DATABASE_URL在本地最喜欢的mySQL管理工具中创建连接,以将数据恢复/备份等数据到ClearDB。你甚至可能会发现heroku db:push会起作用,但我个人并没有尝试过,所以会猜测。

#2


2  

The problem is that Heroku does not use a MySQL database in production, but a PostgreSQL database.

问题是Heroku不会在生产中使用MySQL数据库,而是使用PostgreSQL数据库。

Therefore you will run into all sorts of issues pulling and pushing data from a different database engine. Taps is an activerecord based process that will reduce this problem but not all the time.

因此,您将遇到从不同的数据库引擎中提取和推送数据的各种问题。 Taps是一个基于活动记录的过程,可以减少这个问题,但不是所有时间。

Ideally you want to use PostgresSQL on your development machine (install via Homebrew for simplicity on OSX) and you'll not see any more of these problems.

理想情况下,您希望在开发计算机上使用PostgresSQL(通过Homebrew安装以简化OSX),您将不会再看到这些问题。

Alternatively, use one of the MySQL addons as described in the comments in the question.

或者,使用问题评论中描述的MySQL插件之一。