[英]Heroku, cant push my db
I am trying to push my database to heroku, and get this error: 我正在尝试将数据库推送到heroku,并出现以下错误:
Taps Server Error: PGError: ERROR: invalid byte sequence for encoding "UTF8": 0x89
I am using mysql in my local db, and i have coding utf8 in application.rb. 我在本地数据库中使用mysql,并且在application.rb中编码了utf8。 I have try to push with
我试图推动
heroku db:push
or with 或搭配
heroku db:push mysql2://root:pasword@127.0.0.1/damp?encoding=utf8
What can i do to fix this? 我该怎么做才能解决此问题?
Somewhere in your database there is a character that needs to be encoded in UTF-8, which isn't currently. 在数据库中的某个地方,需要使用UTF-8编码一个字符,目前还没有。 I have had this bug in the past and the only solution is to find it out and change it.
我过去曾遇到过这个错误,唯一的解决方案是找出并更改它。 Painful if you have a large database.
如果您的数据库很大,就很痛苦。
In a comment you mention that you have binary images in your database. 在评论中,您提到数据库中有二进制映像。 The error you're seeing:
您看到的错误:
Taps Server Error: PGError: ERROR: invalid byte sequence for encoding "UTF8": 0x89
Taps Server错误:PG错误:错误:编码“ UTF8”的字节序列无效:0x89
is coming from some sort of text column, either varchar
or text
. 来自某种文本列,即
varchar
或text
。 In MySQL you want one of the BLOB types , in PostgreSQL you want a BYTEA
column , and in with ActiveRecord you want the binary
column type . 在MySQL中,您需要BLOB类型之一 ;在PostgreSQL中,您需要
BYTEA
列 ;在ActiveRecord中,您需要binary
列类型 。 Your table definition should look something like this: 您的表定义应如下所示:
create_table :your_table do |t|
#...
t.binary :image_column_name
#...
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.