Re: Transfer from MySQL to PostgreSQL

Lists: pgsql-novice
From: Adam Witney <awitney(at)sgul(dot)ac(dot)uk>
To: Andrea <andrea(dot)b73(at)email(dot)it>, pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Transfer from MySQL to PostgreSQL
Date: 2006-03-28 09:44:38
Message-ID: C04EC416.5A0C3%awitney@sgul.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On 28/3/06 10:49 am, "Andrea" <andrea(dot)b73(at)email(dot)it> wrote:

> I have both MySQL (5.0) and PostgreSQL (8.1) database servers on my PC.
>
> On MySQL I have a table (very simple, only 7 char fields) filled with
> about 35000 records. On PostgreSQL I have created the same table
> structure (same fields, names, indexes, etc...). I would like to
> transfer all records from MySQL to PostgreSQL.
> Which is the easiest and shortest way to do this??
>
> I know this question is related to a software extern to PostgreSQL,
> however, I hope someone can help me. Thank.

If you can get the data out of the MySQL table into a simple tab delimited
text file, then that is very easy to get it into PostgreSQL using the COPY
command

http://www.postgresql.org/docs/8.1/static/sql-copy.html

(I don't use MySQL though, so can't tell you how to get it into the file)

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


From: Andrea <andrea(dot)b73(at)email(dot)it>
To: pgsql-novice(at)postgresql(dot)org
Subject: Transfer from MySQL to PostgreSQL
Date: 2006-03-28 09:49:16
Message-ID: 4429069C.6090404@email.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

I have both MySQL (5.0) and PostgreSQL (8.1) database servers on my PC.

On MySQL I have a table (very simple, only 7 char fields) filled with
about 35000 records. On PostgreSQL I have created the same table
structure (same fields, names, indexes, etc...). I would like to
transfer all records from MySQL to PostgreSQL.
Which is the easiest and shortest way to do this??

I know this question is related to a software extern to PostgreSQL,
however, I hope someone can help me. Thank.


From: Christoph Frick <frick(at)sc-networks(dot)com>
To: Andrea <andrea(dot)b73(at)email(dot)it>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Transfer from MySQL to PostgreSQL
Date: 2006-03-28 10:07:22
Message-ID: 20060328100722.GZ13909@byleth.sc-networks.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Tue, Mar 28, 2006 at 11:49:16AM +0200, Andrea wrote:

> I have both MySQL (5.0) and PostgreSQL (8.1) database servers on my PC.
> On MySQL I have a table (very simple, only 7 char fields) filled with
> about 35000 records. On PostgreSQL I have created the same table
> structure (same fields, names, indexes, etc...). I would like to
> transfer all records from MySQL to PostgreSQL. Which is the easiest
> and shortest way to do this??

dump the database with insert statements (maybe newer versions of
mysqldump can also dump only one table's data), remove the stuff, that
is not needed with postgres, fix the table names and so on with an
editor of your choice and run the resulting file with psql.

--
cu


From: "Guido Barosio" <gbarosio(at)gmail(dot)com>
To: "Christoph Frick" <frick(at)sc-networks(dot)com>
Cc: Andrea <andrea(dot)b73(at)email(dot)it>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Transfer from MySQL to PostgreSQL
Date: 2006-03-28 12:22:39
Message-ID: f7f6b4c70603280422h75801566p14812970fdc4fa1c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Use SELECT ...INTO OUTFILE and treat the data as a csv while importing
with COPY from the pgsql side.

from mysql docs: The SELECT ... INTO OUTFILE 'file_name' form of
SELECT writes the selected rows to a file. The file is created on the
server host, so you must have the FILE privilege to use this syntax.
file_name cannot be an existing file, which among other things
prevents files such as /etc/passwd and database tables from being
destroyed. As of MySQL 5.0.19, the character_set_filesystem system
variable controls the interpretation of the filename.

Avoid the /etc/passwd line >:}

g.-

On 3/28/06, Christoph Frick <frick(at)sc-networks(dot)com> wrote:
> On Tue, Mar 28, 2006 at 11:49:16AM +0200, Andrea wrote:
>
> > I have both MySQL (5.0) and PostgreSQL (8.1) database servers on my PC.
> > On MySQL I have a table (very simple, only 7 char fields) filled with
> > about 35000 records. On PostgreSQL I have created the same table
> > structure (same fields, names, indexes, etc...). I would like to
> > transfer all records from MySQL to PostgreSQL. Which is the easiest
> > and shortest way to do this??
>
> dump the database with insert statements (maybe newer versions of
> mysqldump can also dump only one table's data), remove the stuff, that
> is not needed with postgres, fix the table names and so on with an
> editor of your choice and run the resulting file with psql.
>
> --
> cu
>
>
>

--
Guido Barosio
-----------------------


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Guido Barosio <gbarosio(at)gmail(dot)com>
Cc: Christoph Frick <frick(at)sc-networks(dot)com>, Andrea <andrea(dot)b73(at)email(dot)it>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Transfer from MySQL to PostgreSQL
Date: 2006-04-10 22:27:41
Message-ID: 200604102227.k3AMRg323689@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Guido Barosio wrote:
> Use SELECT ...INTO OUTFILE and treat the data as a csv while importing
> with COPY from the pgsql side.
>
>
> from mysql docs: The SELECT ... INTO OUTFILE 'file_name' form of
> SELECT writes the selected rows to a file. The file is created on the
> server host, so you must have the FILE privilege to use this syntax.
> file_name cannot be an existing file, which among other things
> prevents files such as /etc/passwd and database tables from being
> destroyed. As of MySQL 5.0.19, the character_set_filesystem system
> variable controls the interpretation of the filename.

I think you also have to be careful that NULL's are transfered cleanly
from one database to the other.

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +