viernes, 16 de octubre de 2009

How to migrate MySQL backup to PostgreSQL

Hi, the first step is generate a dump with all data from your mysql database. for example. I am working in Ubuntu 8.04 Hardy Heron


cmonterrosa@dibd02:~$ mysqldump dbname > file.sql -u root -p


enter your password and mysqldump generate a file with the BD backup. then you have tu run the script to format this file.sql into postgresql valid format.

This script is available in:

http://pgfoundry.org/frs/download.php/1535/mysql2pgsql.perl


cmonterrosa@dibd02:~$ perl mysql2pgsql.perl file.sql file-pgsql.sql



where file-pgsql.sql is the file valid for introduce the schema and data into postgresql.Now we are going to restore the schema and the rows.


cmonterrosa@dibd02:~$ psql -h localhost -d diccionarios -U cmonterrosa -W


where -h option is host, in this case is the localhost, -d is the database and -U is the owner of the database.

Comments with

Carlos Augusto Monterrosa Lopez
cmonterrosa@gmail.com / cmonterrosa@sef-chiapas.gob.mx

No hay comentarios: