Re: Mysql migration to Postgresql

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: mrciken <mik(dot)wen(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Mysql migration to Postgresql
Date: 2009-11-26 01:51:50
Message-ID: 4B0DDF36.9020400@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

mrciken wrote:
> Hello,
>
> Currently, we are using Mysql: we would like to change. Now, we would like
> to use Postgresql. Only problem is that most of our customer addresses and
> other information are on Mysql.

> Can you help us with this?

There are a few options available to you. This has been extensively
discussed in the archives, which are indexed by Google, so you can find
a lot out with a few Google searches. One of the first hits is:

http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#MySQL

In my opinion, the best option is usually to write a new set of SQL
scripts to create the required tables etc in PostgreSQL, using the same
table and column names etc as your existing MySQL database and adapting
types as appropriate. That will ensure you get a fairly clean, sane
setup in PostgreSQL and also helps make sure you understand the database
you're working with. Once you've run the SQL scripts you wrote to create
the required (empty) tables in the new PostgreSQL database, import just
the data from MySQL into the waiting tables in PostgreSQL. You can do
the data import by loading an SQL dump created in MySQL using "psql"
(though some fixing and conversion may be required), using a script or
database access program connected to both databases at once, or however
else you like.

Doing things this way will let you write a good quality table structure
for PostgreSQL, ensuring that things are done sensibly and handling
issues like converting from AUTO_INCREMENT to sequences properly,
converting any use of full text search, etc. However, you'll want to
read the documentation thoroughly.

Another option is to use one of the automated conversion tools and see
how you go. You can always refine the schema it creates once the
conversion is done. Personally, I've never been happy with the results
of doing things that way, though.

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2009-11-26 02:38:56 Re: limiting resources to users
Previous Message Filip Rembiałkowski 2009-11-26 01:44:50 Re: Mysql migration to Postgresql