开发者

How to dump data from mysql database to postgresql database?

I have done the depot application using mysql... Now i am in need to use postgres... So i need to du开发者_C百科mp data from mysql database "depot_development" to postgres database "depot_develop"...


Here you can find some interesting links http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#MySQL


Have you tried to copy the tables from one database to the other:

a) export the data from MySQL as a CSV file like:

$> mysql -e "SELECT * FROM table" -h HOST -u USER -p PWD -D DB > /file/path.csv'

and then,

b) import it into Postgres like:

COPY table FROM '/file/path.csv' WITH CSV;


This question is a little old but a few days ago i was dealing with this situation and found pgloader.io.

This is by far the easiest way of doing it, you need to install it, and then run a simple lisp script (script.lips) with the following 3 lines:

/* content of the script.lisp */
LOAD DATABASE
FROM mysql://dbuser@localhost/dbname
INTO postgresql://dbuser@localhost/dbname;


/*run this in the terminal*/
pgload sctipt.lisp

And after that your postgresql DB will have all of the information that you had in your MySQL SB

On a side note, make you you compile pgloader since at the time of this post, the installer has a bug. (version 3.2.0)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜