Portal Home > Knowledgebase > Articles Database > convert mysql to postgresql?


convert mysql to postgresql?




Posted by surfmanjoe, 06-07-2009, 05:08 PM
I need convert a huge (more than 4G) mysql db to the latest version of postgresql. I have root right to both db. but I have no idea on how to do it. is there anyone may help me out? I googled the Internet and found a tool named DBConvert. what else way to do it? Thanks.

Posted by cselzer, 06-07-2009, 10:34 PM
mysqldump databasename -e -t > mydatabaseinserts.sql replace database name with the database name... that gets all of the insert statements, this would make an sql file with ALL of the inserts for that database. Now, make ALL the tables manually on the postgres database.. (i would anyways if you're sql savvy, to ensure you get exactly what you need) and then just use AFTER you created the tables in postgresql. pgsql databasename < mydatabaseinserts.sql I've personally never done it like this, but i assume it would work, because i use the same inserts for pgsql and mysql for an installation of a script i wrote in php.. and different create table structure (no such thing as autoincrement, its serial in postgresql) This will most likely take quite a while... heh. But it will do it, i'd probably let it sit for an hour or 2 perhaps. Let me know your results, or if you have any other questions, please post back. ill get an email on my phone when you reply

Posted by Daniel15, 06-12-2009, 11:21 PM
You might want to use instead. This will make sure there's no MySQL-specific SQL in the dump file, and I think it also changes some stuff so the file works in Postgres.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read