No commit activity in last 3 years
No release in over 3 years
It can create postgresql dump from mysql database or directly load data from mysql to postgresql (at about 100 000 records per minute). Translates most data types and indexes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.21
~> 1.5.2
~> 0.9.2.2
~> 3.12
>= 2.1.1

Runtime

= 2.8.1
>= 0
 Project Readme

MYSQL2PSQL - MySQL to PostgreSQL Migration Tool¶ ↑

Tool for converting mysql database to postgresql. It can create postgresql dump from mysql database or directly load data from mysql to postgresql (at about 100 000 records per minute).

It can translate now most data types and indexes, but if you experience some problems, feel free to contact me, I’ll help you.

Installation¶ ↑

Mysql2psql is packaged as a gem. Install as usual (use sudo if required).

$ gem install mysql2psql

After installation, the “mysql2psql” command will be available. When run, it will generate a default configuration file in the current directory if a config file is not already found. The default configuration filename is mysql2psql.yml.

$ mysql2psql

You can use an alternate config file by passing the filename/path as a parameter:

$ mysql2psql ../another/world.yml

Running Migrations¶ ↑

See the configuration file for documentation about settings. Key choices include:

  • whether to dump to a file, or migrate direct to PostgreSQL

  • migrate only the schema definition, only the data, or both schema and data

After editing the configuration file and launching tool, you will see something like..

Creating table friendships...
Created table friendships
Loading friendships...
620000 of 638779 rows loaded. [ETA: 2010/01/21 21:32 (00h:00m:01s)]
638779 rows loaded in 1min 3s
Indexing table friendships...
Indexed table friendships
Table creation 0 min, loading 1 min, indexing 0 min, total 1 min

Database driver dependencies¶ ↑

Mysql2psql uses the ‘mysql’ and ‘pg’ gems for database connectivity. Mysql2psql gem installation should automatically install these too.

If you encounter any issues with db connectivity, verify that the ‘mysql’ and ‘pg’ gems are installed and working correctly first. The ‘mysql’ gem in particular may need a hint on where to find the mysql headers and libraries:

$ [sudo] gem install mysql -- --with-mysql-dir=/usr/local/mysql

NB: With Ruby 1.8.x, the gem install will usually complain about “No definition for …” errors. These are non-fatal and just affect the documentation install. This doesn’t happen with Ruby 1.9.2.

Contributing to Mysql2psql¶ ↑

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so no-one unintentionally breaks it in a future version.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so the gem maintainers can cherry-pick around it.

  • Send a pull request

Getting the source¶ ↑

Mysql2psql was first produced by Max Lapshin <max@maxidoors.ru> who maintains the master repository at github.com/maxlapshin/mysql2postgres

The gem bundling and refactoring for testing was done by Paul Gallagher <gallagher.paul@gmail.com> and the repository is at github.com/tardate/mysql2postgres

Gem packaging is done with Jeweler. Note that on windows this means you must run under mingw or other shell that supports git to do the gem bundling (but you can gem install the built gem in the normal Windows shell).

Setting up for development¶ ↑

The project includes a Gemfile so with bundler you can install gem dependencies with:

gem install bundler # if not already installed
bundle install

Note comments ‘Database driver dependencies’ regarding issues that you may encounter with the mysql gem.

Running tests¶ ↑

If you fork/clone the project, you will want to run the test suite (and add to it if you are developing new features or fixing bugs).

A suite of tests are provided and are run using rake (rake -T for more info)

rake test:units
rake test:integration
rake test

Rake without parameters (or “rake test”) will run both the unit and integration tests.

Unit tests are small standalone tests of the mysql2psql codebase that have no external dependencies (like a database)

Integration tests require suitable mysql and postgres databases to be setup in advance. Running the integration tests will rewrite data and schema for the “mysql2psql_test” databases in mysql and postgres. Don’t use this database for anything else!

Setting up mysql on localhost:3306

  • create a database called “mysql2psql_test”

  • setup a user “mysql2psql” with no password

e.g.

mysqladmin -uroot -p create mysql2psql_test
mysql -uroot -p -e "grant all on mysql2psql_test.* to 'mysql2psql'@'localhost';"
# verify connection:
mysql -umysql2psql -e "select database(),'yes' as connected" mysql2psql_test

Setting up PostgreSQL on localhost:5432

  • create a database called “mysql2psql_test”

  • setup a role (user) “mysql2psql” with no password

e.g.

psql postgres -c "create role mysql2psql with login"
psql postgres -c "create database mysql2psql_test with owner mysql2psql encoding='UTF8'"
# verify connection:
psql mysql2psql_test -U mysql2psql -c "\c"

Notes, Limitations, Outstanding Issues..¶ ↑

  • more test coverage, as always…

Contributors¶ ↑

Project founded by Max Lapshin <max@maxidoors.ru>

Contributors (roughly git log order):

  • Anton Ageev <anton@ageev.name>

  • Samuel Tribehou <cracoucax@gmail.com>

  • Marco Nenciarini <marco.nenciarini@devise.it>

  • James Nobis <jnobis@jnobis.controldocs.com>

  • quel <github@quelrod.net>

  • Holger Amann <keeney@fehu.org>

  • Maxim Dobriakov <closer.main@gmail.com>

  • Michael Kimsal <mgkimsal@gmail.com>

  • Jacob Coby <jcoby@portallabs.com>

  • Neszt Tibor <neszt@tvnetwork.hu>

  • Miroslav Kratochvil <exa.exa@gmail.com>

  • Paul Gallagher <gallagher.paul@gmail.com>

  • James Coleman <jtc331@gmail.com>

  • Aaron Peckham

  • James Tippett

  • Tim Morgan

  • dakhota

  • Matthew Soldo