Giter Site home page Giter Site logo

mysql2pgsql's Introduction

Migrating from MySQL to Postgresql

Step 1: Create a proper mysql dump

mysqldump --hex-blob dbname > dbname_mysql.sql

Step 2: Convert your dump to postgres style

Use the included script. I've fixed it up with better support for foreign keys (it puts all the constraint creation at the bottom of the file) and FKs with multiple column references.

./mysql2pgsql.pl --sepfile constraints.sql --nodrop dbname_mysql.sql dbname_pg.sql

Step 3: Import

Make sure you have created the database first.

psql -f dbname_pg.sql `psql -f constraints.sql

Notes:

  • If you want to be notified of errors in your dump, do \set ON_ERROR_STOP 1

  • Make sure your mysql tables are all utf8 first

  • Dumps do not work well with BLOB data. MySQL uses 0x1234, Pg uses E'\x1234'. Don't use BLOBs if you can avoid it in general.

  • The test directory contains some simple tests, which are not comprehensive. cd test; ./run_test.sh to run the tests.

  • If you have anything to add, please let me know

mysql2pgsql's People

Contributors

ahammond avatar bruc avatar revmischa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.