Question : How do I copy a MySQL Database from one Linus box to another?

I need to move a website from one Linux box to another.

I would like to copy a couple of MySQL databases from the old box to the new one.

I have root access to both machines via SSH. Both machines are located in the same data center (The Planet).

How do I do this from my SSH command prompt?

Source Box
IP=x.x.x.x
OSTYPE=linux-gnu
MACHTYPE=i386-redhat-linux-gnu
uname -a=Linux ensim.xxx.com 2.6.9-55.0.2.ELsmp #1 SMP Tue Jun 12 17:59:08 EDT 2007 i686 i686 i386 GNU/Linux
ControlPanel=Ensim Pro X
MySQL Version=Ver 14.7 Distrib 4.1.20, for redhat-linux-gnu (i686) using readline 4.3
Database Name=XXX
MySQL Data Directory=/var/lib/mysql/XXX
The files here are owner:group =

Destination Box
IP=y.y.y.y
OSTYPE=linux-gnu
MACHTYPE=i686-redhat-linux-gnu
uname -a=Linux plesk.xxx.com 2.6.18-194.3.1.el5PAE #1 SMP Thu May 13 13:48:44 EDT 2010 i686 i686 i386 GNU/Linux
ControlPanel=Plesk 9.4
MySQL Version=Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (i686) using readline 5.1
Database Name=YYY
MySQL Data Directory=/var/lib/mysql/YYY
The files here should be owner:group = mysql:mysql

Answer : How do I copy a MySQL Database from one Linus box to another?

The plain copy action is easy:

At the source box command prompt, type

cd /home/virtual/site1/fst/var/www/html
tar -czpf web_site_files.tar.gz *

Assuming, you don't log in as root but as a user and then su to root...

scp web_site_files.tar.gz [email protected]:


Now, at the destination box command prompt:

su - root
cd /var/www/vhosts/mydomain.com/httpdocs

tar -xzpf ~user/web_site_files.tar.gz
chown -R apache:apache *

Keep in mind, though, that this might not work right of the bat. Your environment might need more configuration.
Random Solutions  
 
programming4us programming4us