0

I have a a MySQL database that stores PHP objects in serialized format to a BLOB field. I'm moving this database from MySQL -> PostGres.

So far I have found no way to move those PHP objects to PostGres. Saving the objects serialized to a MySQL field of type BLOB or MySQL LongText, and importing into PostGres Text or ByteA, apparently fails to bring the data over when imported.

I'm happy to write special-purpose code to store the PHP objects in any way that will work. What's a good way to store them in MySQL so as to import them into PostGres?

Note: Per request of StackOverflow, this question is different from Storing large JSON - binary or text, because that question does not reference postgres.

Community
  • 1
  • 1
VikR
  • 3,484
  • 3
  • 34
  • 70
  • This person seems to have found an answer http://dba.stackexchange.com/questions/4211/how-to-migrate-large-blob-table-from-mysql-to-postgresql about migrating a blob table to PostgreSQL. – vielmetti Dec 28 '16 at 02:15
  • store as JSONB instead, or just json in the text/blob field, and then import into a JSON field – Andrew Dec 28 '16 at 02:38
  • 2
    Possible duplicate of [Storing large JSON - binary or text](http://stackoverflow.com/questions/41198808/storing-large-json-binary-or-text) – e4c5 Dec 28 '16 at 02:45

1 Answers1

0

A data transfer tool (Valentina Pro), copied the mySQL BLOB fields to PostGres ByteA fields. This code retrieved the serialized string from the contents of this field:

$serializedString = pg_unescape_bytea($contentsOfPostGresByteAField);

Thanks to Sergey Pashkov for the tip!

VikR
  • 3,484
  • 3
  • 34
  • 70