MySQL – Export & Import Database to new server

Last updated on March 29th, 2018 at 02:33 pm

First, Create new Database through CLI (New Server):

Run on cli:

mysql -u root -p
Enter password

Run on mysql cli:

create database NewSiteDB01;

Export old database ‘MySiteDB01’ to .sql db file through CLI (Old Server):
Run on cli:

mysqldump -u root -p MySiteDB01 > MySiteDB01_backup.sql
Enter password
exit

Import ‘MySiteDB01_backup.sql’ file to the new database ‘NewSiteDB01’ through CLI (New Server):
Copy .sql file from Old server path to New server /home directory
Run on cli:

mysql -u root -p NewSiteDB01 < /home/MySiteDB01_backup.sql
Enter password
exit