March 26, 2023

Frigorifix

General Blog

Migrating Database from MySQL to PostgreSQL  

Although both MySQL and PostgreSQL are considered as fantastic Database Management Systems with numerous tools and APIs, there are a number of advantages that give PostgreSQL the lead over MySQL. PostgreSQL has a wide range of support offering both synchronous and asynchronous replication, it has asynchronous “commit” feature, it can work with various modes of indexing and lastly it is totally compiled with ANSI SQL standard.

Being informed of the advantages PostgreSQL provides, many businesses have considered moving their database from MySQL to PostgreSQL. Usually, database migration is a long and hefty process. It can be summarized into the following steps:

  1. The table definitions with their indexes and restrictions should be extracted from the initial database to create SQL                 CREATE-statements
  2. These CREATE-statements are then converted into destination files and loaded into the final database
  3. Data from MySQL is exported in form of a CSV file
  4. In the form of SQL statements or source code views, triggers and stored procedures are extracted from the original database
  5. These statements and the source code will be converted to a destination file and then loaded into PostgreSQL database and you are done!

As mentioned, database migration can be a very difficult process carrying it out manually. To add, if not handled properly all of your data could get corrupted. Considering this in mind, it would be better to opt for specialized software for database migration.

Luckily, there are several tools available for this job. However, one of the best ones in the market would be MySQL to PostgreSQL data migration developed by Intelligent Converters — working in this sector of database conversion since 2001. Some of the benefits of the converter are listed below:

  1. This tool is rapid (It can transfer upto 10,000 records per second on an average modern computer). This is achieved by its direct reading and writing of data without using any intermediary libraries
  2. It can work with any version of MySQL or PostgreSQL including cloud solutions
  3. It comes with a command line version
  4. It allows the user to not only migrate old MySQL data onto a new database but it also can be used to join or synchronize converted data with old PostgreSQL database

Another feature which makes this converter stand out is the filtering option. Only data required or certain records can be migrated to the destination database. Select particular columns, or records and even transform it beforehand. Then convert it to PostgreSQL format. This feature can be used in different ways:

  • To filter records
  • To select and rename individual columns
  • To join multiple tables

Usually, you are required to alter the column type when transferring data into a new database. To help with this process the converter has a feature named “custom column mapping”. Through this feature, you can edit different attributes of a column. It will also let you decide which columns you want to include in the edit.

Another advantage of this converter is that in case, your PostgreSQL server has no option for remote connection, you can transport your data in the form of a SQL script. For this, the local database is converted into a document with SQL-statements with command for creating tables as per requirement. Then this file can be imported into the PostgreSQL server and used with tools like phpPgAdmin or psql.