the question is that how can I migrate a postgres database to a mysql server?
|
feedback
|
migrated from stackoverflow.com May 6 '11 at 7:34
This question came from our site for professional and enthusiast programmers.
|
There is no easy way to do this since they are many differences in syntax. You will need to start by getting your data out of PostgresSQL, either by dumping data or outputting each table as a CSV file. e.g.
You will then need to recreate the table structures in MySQL, either by hand or perhaps via something like pg2mysql which will save time by doing a lot of the table scripting for you from a dump file, however there may be issues with data conversion this way so be prepared to migrate some data via CSV files (documented here). You will need to recreate any stored procedures, users and privileges by hand. There are tools that will do this whole thing for you at a cost (for example DBConvert which I haven't used myself), which might be worth the cost if you have a large and complex database and need to save time over cost. My experience of such tools is that although they do most of the work quickly and simply there will always be exceptions and in the end you'll waste more time finding and sorting these out than might be worth it. It depends on your situation which is the best method. If you are using a CMS or alike, most likely there will already be a script to create a MySQL database, and all the contents except the data, in which case a lot of the hard work is done for you and you only need to deal with INSERT INTO statements from the dump (and/or CSV imp/exp). If you wrote your own in-house database only you know if it is a few simple tables or some giant complex beast that crushed the spirit of the last dozen DBAs. Be methodical, document as you go, develop a repeatable process where each step is simple and is checked. It's all too easy to just move it all over in one click of your shiny new tool, accept it as done and nonchalantly say that you'll just "bish-bash-bosh" any little oddities as you find them. If you care that little about the data why even take it? You'll also find that something like HeidiSQL will be a big help with running SQL, importing CSV files and checking data once you get to MySQL (and it is helpful in managing the MySQL database afterwards). | |||
|
feedback
|