DebugQ - De:Bug:Q

Go Back   DebugQ - De:Bug:Q > DebugQ > Linux
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
Thread Tools Display Modes
  #1  
Unread 09-14-2015, 12:44 PM
Debugger Debugger is offline
Administrator
 
Join Date: Oct 2007
Posts: 895
Default How To Migrate a MySQL Database Between Two Servers

Q: How To Migrate a MySQL Database Between Two Servers


   

Reply With Quote
  #2  
Unread 09-14-2015, 12:45 PM
Debugger Debugger is offline
Administrator
 
Join Date: Oct 2007
Posts: 895
Default

Step One

Perform a MySQL Dump

Before transferring the database file to the new VPS, we first need to back it up on the original virtual server by using the mysqldump command.

mysqldump -u root -p --opt [database name] > [database name].sql

After the dump is performed, you are ready to transfer the database.


   

Reply With Quote
  #3  
Unread 09-14-2015, 12:46 PM
Debugger Debugger is offline
Administrator
 
Join Date: Oct 2007
Posts: 895
Default

Step Two

Copy the Database

SCP helps you copy the database. If you used the previous command, you exported your database to your home folder.

The SCP command has the following syntax:

Code:
scp [database name].sql [username]@[servername]:path/to/database/

A sample transfer might look like this:

scp newdatabase.sql user@example.com:~/

After you connect, the database will be transferred to the new virtual private server.


   

Reply With Quote
  #4  
Unread 09-14-2015, 12:47 PM
Debugger Debugger is offline
Administrator
 
Join Date: Oct 2007
Posts: 895
Default

Step Three

Import the Database


Once the data has been transferred to the new server, you can import the database into MySQL:

mysql -u root -p newdatabase < /path/to/newdatabase.sql

With that, your transfer via SCP will be complete.


   

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump


All times are GMT. The time now is 04:06 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
DebugQ - Debug Quote - De:Bug:Q