I am trying to push my database to heroku, and get this error:
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. 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. 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
is coming from some sort of text column, either varchar
or 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 . Your table definition should look something like this:
create_table :your_table do |t|
#...
t.binary :image_column_name
#...
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.