snippetsqlCritical
How can I move a database from one server to another?
Viewed 0 times
canmovedatabaseoneanotherhowserverfrom
Problem
How can I move MySQL tables from one physical server to another?
Such as this exact scenario:
I have a MySQL server that uses innodb table and is about 20GB size.
I want to move it to a new server, what's the most efficient way to do this?
Such as this exact scenario:
I have a MySQL server that uses innodb table and is about 20GB size.
I want to move it to a new server, what's the most efficient way to do this?
Solution
My favorite way is to pipe a sqldump command to a sql command. You can do all databases or a specific one. So, for instance,
You can do all databases with
The only problem is when the database is too big and the pipe collapses. In that case, you can do table by table or any of the other methods mentioned below.
mysqldump -uuser -ppassword myDatabase | mysql -hremoteserver -uremoteuser -premoteserverpasswordYou can do all databases with
mysqldump --all-databases -uuser -ppassword | mysql -hremoteserver -uremoteuser -premoteserverThe only problem is when the database is too big and the pipe collapses. In that case, you can do table by table or any of the other methods mentioned below.
Code Snippets
mysqldump -uuser -ppassword myDatabase | mysql -hremoteserver -uremoteuser -premoteserverpasswordmysqldump --all-databases -uuser -ppassword | mysql -hremoteserver -uremoteuser -premoteserverContext
StackExchange Database Administrators Q#174, answer score: 101
Revisions (0)
No revisions yet.