Sunday 21 November 2010

MySQL to PostgreSQL migration


According to common sense mysql to postgre migration should be work with dump mysql script to file (A) and import script(A) to postgre but its not that simple because mysql and postgre has different syntax.so we need to change syntax before import sql file to postgre.There are perl scripts which will help us to change mysql dump file to postgre dump file we can use that wrapper file to change syntax bulk operation.

perl mysql2perl.perl mysqldump.sql(A) postgredump.sql(B)
now we can import compatible postgre script to postgre databse.

therefor abstract of above operations as follows,
Psuedo,

mysqldump --compatible=postgresql -u username -ppassword databse> mysqldump.sql(A);
perl mysql2pg.perl mysqldump.sql(A) postgredump.sql(B);
psql -h localhost -d postgredatabse -U postgres -W < postgredump.sql(B);

here you can find the mysql2pg.perl script,

Backups
Postgres backup

pg_dump -h localhost - drupaldb -U postgres > /file path/file.sql