1

I want to migrate database from mysql to postgresql. So, first did the mysqldump with this command

mysqldump -u root -p --compatible=postgresql --default-character-set=utf8  databasename > output.sql

Then i upload the output.sql to host and import the sql file using below command

psql -U root -d databasename -f /home/test/output.sql

But i got error when i try to import

ERROR:  syntax error at or near "KEY"   
ERROR:  syntax error at or near "UNLOCK"  
ERROR:  syntax error at or near "("       
invalid command \n        
invalid command \'></script>       
invalid command \";s:2:          
invalid command \',        
invalid command \']       
Query buffer reset (cleared).

The size of database that I dumped is 7.5gb.

0

1 Answer 1

3

The SQL used in MySQL and that used in Postgres are not one-to-one inter-compatible. You need a converter program for anything non-trivial.

From the documentation for --compatible:

This option does not guarantee compatibility with other servers.

In other words, it's only slightly more compatible.

There are commercial products like Navicat which can help do this for you automatically, or you can dump out all your MySQL data in a neutral format like XML, JSON or CSV and read it back in using some other tool.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.