We are Borg
We are Borg

Reputation: 5311

MySQL : Copy all databases from one server to another

I am working on migrating one of our project which requires MySQL to another server. I am looking for a way to migrate all the created databases by the users to another server. For starting, I tried out to move only one database, but it's not working.

Attempt :

mysqldump db_name | mysql -h root@migration_server.com target_db(same name);

Error :

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'command as above' at line 1

What am I doing wrong? Anything on the 2nd server I need to set or something else. Thank you.

Upvotes: 0

Views: 1329

Answers (1)

Priyanshu
Priyanshu

Reputation: 881

Taking Dump.

  mysqldump -uroot -p --port= <3306 or 3309> db_name > "d:\target_db.sql";

restoring dump

mysqldump -uroot -p  db_name < "d:\target_db.sql";

Mentioning port is optional.

Upvotes: 2

Related Questions