Thursday, February 23, 2012

MySQL . mysqldump. exporting data with sql inserts to PostgreSQL

Generating a working mysql data dump with inserts to load into PostgreSQL.

Key options for generating the dump.

mysqldump -u user  --extended-insert=FALSE --no-create-info --compact --compatible=postgresql database > file.sql

Converting incompatible characters
sed "s/\\\'/\'\'/g" file.sql > file1.sql

And importing into postgresql
psql database < file1.sql
That was quick, wasn't it? References: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html http://chriswa.wordpress.com/2008/02/20/mysqldump-data-only/ http://en.wikibooks.org/w/index.php?title=Programming:Converting_MySQL_to_PostgreSQL

No comments:

Post a Comment