There are situations where I want to decide for myself what to do, e. g. if there is a datatype in MySQL that's not present in PgSql.
I see your point, but I think it also depends on the migration strategy. I had to do a lot of manual work, but I prefer to do it carefully step by step to having things automated too much.
I would like to migrate a mysql database to pgsql.
I would like to do it table for table.
Can you export a table into a plain-text SQL file so that it can be edited and imported in pgsql?
I would like to migrate a mysql database to pgsql.
I would like to do it table for table.
Hi,
I would like to migrate a mysql database to pgsql.
I would like to do it table for table.
Can you export a table into a plain-text SQL file so that it can be
edited and imported in pgsql?
mysqldumpUsage: mysqldump [OPTIONS] database [tables]
mysqldump test test | grep -v '^/'-- MySQL dump 10.14 Distrib 5.5.45-MariaDB, for Linux (x86_64)
Magnus Warker schrieb am 30.10.2015 um 20:00:
Ora2Pg has been a reliable tool to migrate from Oracle to Postgres.
The latest release also supports migrating from MySQL to Postgres, you
might want to look into that:
http://ora2pg.darold.net/
I gave it a try. But the documentation is for Oracle only. After the section "Generate a migration template" everything is related to Oracle.
Did you try pgloader?
I'd like to post my experiences here, for other people in the same
situation and for my own reference. :-)
The migration is done on my production system and it was done without
any pain or problems! If I knew that it would go this way I wouldn't
have postponed it for years. This will be my method of choice, if I have
to do it again someday.
Here is how it was done:
3. evolve a migration script
Evolve a SQL script that fetches the data from the migration tables and writes it into the new tables. This script containes some SQL statements
for each of the tables in the new database, like this:
DELETE FROM apl_table1;
INSERT INTO apl_table1 (atr1,...,atrn)
SELECT (atr1,...,atrn) FROM mig_table1;
4. switch the database
Finally, I changed the migration instance of the application to the main production instance. The migration script must be executed one last time immediately before this step, so that the latest changes to the old
database make it to the new database.
In spite of all the differences between the two DBMS and the SQL
dialects this change could be performed without any incicents. My
application (a chess system) continued to work and my users didn't
notice anything.
(Besides that, I feel that it's running a bit faster now...)
Thank you very much Harry for pointing me to mysql_fdw.
I enjoyed it. :-)
On 06.01.2016 06:43, Magnus Warker wrote:
3. evolve a migration script
Evolve a SQL script that fetches the data from the migration tables and
writes it into the new tables. This script containes some SQL statements
for each of the tables in the new database, like this:
DELETE FROM apl_table1;
INSERT INTO apl_table1 (atr1,...,atrn)
SELECT (atr1,...,atrn) FROM mig_table1;
If I understand this correctly your migration script basically emptied
the target PostgreSQL schema and then copied over everything from
scratch. I would assume this is only practical up to a particular
database size. How large was yours?
4. switch the database
In spite of all the differences between the two DBMS and the SQL
dialects this change could be performed without any incicents. My
application (a chess system) continued to work and my users didn't
notice anything.
How could that be? Didn't you require some downtime? I mean, in order
to be sure to not lose data you would have to do
1. Shut down production
2. Migrate data for the last time
3. Fire up new application in production using the new database
I'd like to post my experiences here, for other people in the same situation and for my own reference. :-)
A quick note: have a look at pgloader, a tool that automates all the
steps you're mentionning expect for the switching itself.
http://pgloader.io
The Foreign Data Wrapper approach is a good one too, but the MySQL
driver used to bypass data validation and could fill in the PostgreSQL
tables with e.g. 0000-00-00 dates, which then you can't read back.
There's also the opportunity to cast bit(1) or tinyint(1) columns into
proper boolean ones, and things like that.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 295 |
Nodes: | 16 (2 / 14) |
Uptime: | 05:42:12 |
Calls: | 6,642 |
Calls today: | 2 |
Files: | 12,190 |
Messages: | 5,325,856 |