← back to the blog
fousa blog
Convert MySQL DB to PostgreSQL DB
When I was converting my blog to the heroku, I decided to convert my local database from MySQL to PostgreSQL. This for developing purposes because it's a bad practice to have 2 different systems in development and production.
This is my current setup: 1 local MySQL database with my production dump in it. A new PostgreSQL database that is up and running.
Enter the following command to clone the git repository for the conversion script:
> git clone git://github.com/maxlapshin/mysql2postgres.git convert/The repository is now copied in the convert directory.
The next thing you have to do is modify the config.yml file.
Mine looks like this:
mysql: hostname: localhost port: 3306 socket: /tmp/mysql.sock username: kowalski password: databasename: kowalski_developmentdestination: postgres: hostname: localhost databasename: fousa_development username: jelle password: charset: utf8
tables: comments, posts, tags
Now run the following command in the Terminal:
> ruby mysql2psqlYour data will be copied and converted from your local MySQL database to your local PostgreSQL database.
Send me some feedback!