Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert MySql to PostgreSQL

I want to move from MySQL to PostgreSQL, this is not a live site as yet, going to launch soon and the schema is all ready in MySQL but given the business model I want a better scalable DB, so to convert MySQL to PostgreSQL, do i need to do it manually table by table or are there are GUI tools I can use (or scripts) to automate this conversion for tables/file values?

My app is written in codeingiter PHP.

like image 450
Markus Avatar asked Nov 27 '10 01:11

Markus


People also ask

Is it easy to migrate from MySQL to PostgreSQL?

To connect MySQL to PostgreSQL through Foreign Data Wrapper, you must take note of the following as this is what will be required to create the connection: CREATE EXTENSION command to create a MySQL Foreign Data Wrapper extension to the PostgreSQL host. CREATE SERVER command to define a connection to the MySQL Server.

Can MySQL script run in PostgreSQL?

PostgreSQL will ignore it, MySQL will run it. For more information see the docs. Update: If you want to include commands that are run only on PostgreSQL but not on MySQL, you can exploit the fact that PostgreSQL supports nested comments, and MySQL doesn't.

Is MySQL or PostgreSQL better?

Most developers will tell you that MySQL is better for websites and online transactions, while PostgreSQL is better for large and complicated analytical processes.


2 Answers

The only thing did the job for me was Navicat Premium, You can grab Navicat and use it free for 14 days, which is enough for DB migration...

Just create 2 connections (one source mysql, another target postgresql), and choose Tools -> Data Transfer, and it works!

Other tools I tried: dumping with mysqldump as postgresql compatible - didn't work, as ansi sql - didn't work, tried pgload - didn't work, tried with https://github.com/AnatolyUss/nmig Nmig created tables properly but data was missing.

like image 195
Aleksandar Pavić Avatar answered Oct 15 '22 06:10

Aleksandar Pavić


  1. I agree with Pekka: if you're going to launch soon, the last thing you want to do is switch database systems.
  2. If you're lucky and you're able to export compliant SQL from your current database, Postgres will understand it and little to no extra effort is needed. SQL can be exported to recreate both the structure of your database and the content of its tables.
like image 23
Reinderien Avatar answered Oct 15 '22 04:10

Reinderien