Powered by
Movable Type 3.38 mod_perl/2

Netzwelt MySQL to PostgreSQL

If you want to convert from MySQL to PostgreSQL, use the following command to have mysqldump spit out sane SQL:

% mysqldump $DATABASE_NAME -v -nt --compatible=ansi,postgresql --complete-insert=TRUE --extended-insert=FALSE --compact --default-character-set=UTF8 -u $DATABASE_USER -p -r $OUTPUT_FILE

You should then hoopefully be able to load this dump into your PostgreSQL database using

=> \i $OUTPUT_FILE

from within psql.

This piece of information is hidden deeply within the net! It is not clearly written in the mysqldump docs. There are lots of Google results for “MySQL to PostgreSQL” but most of them are needlessly silly and of doubting quality. Spread this info!

Converting the database schema cannot be handled by witty mysqldump switches and is left as an exercise to the reader.


TrackBack

» MySQL migration to PostgreSQL (manual trackback)
Well, it’s not an easy task, you know, to migrate a MySQL database to PostgreSQL. Especially when you have to deal with a good few gigs of data. Two are the obstacles: * the data types between the two RDBMs do not match; so they have to be conv...

TrackBack URL for this entry:
http://anti.teamidiot.de/mt-tb/42


Comments (2)

Thanks, was really usefull :-)

Once you get the database schema. You might want to exclude complete-inserts=TRUE because if you it could give table param names with mixed cases. In some version PostgreSQL it converts mixed case params schema to lowercase. Which could cause and error with importing. thanks....