 |
| I had been running Apache/2.0.53 (Win32) PHP/5.0.4 and MySQL 4.0.24-nt on Window XP since year 2005. Anyway, I have currently changed my server’s platform from Window XP(old Computer) to Linux Redhat(new Computer). The new server running Apache/2.2.2 (Unix) DAV/2 PHP/4.4.2 and Mysql 4.1.20. Hence, I have to migrate all the data from the old server(running Window XP) to new server(runnng Linux Redhat) including the mysql data.
The following steps show I migrate my mysql data to the new server:
|
| (a) In my old Computer - Running Window XP: |
| i. |
Go to -> C:\mysql\data (i.e. the directory where my mysql data has been installed) |
| ii. |
Find your wanted database - For e.g. MyDatabase. You will see a directory named - MyDatabase. |
| iii. |
As you go into MyDatabase directory, you will notice that every DB’s table consists of 3 files. E.g. table1.frm, table1.MYD, and table1.MYI for table1. |
| iv. |
In case you want to migrate the whole database of MyDatabase, you should copy all the files within the directory MyDatabase(Except db.opt if any - I think this fie only exist in Mysql running on Linux platform.) to somewhere in your new server(i.e Linux paltform). For my case, I have created a temporary directory called MyDatabase in /usr/local/apache2/htdocs/ (i.e. on Linux server) and copy all those required files into /usr/local/apache2/htdocs/MyDatabase. I have chosen this way, just simply because I have connected both computers within a LAN and shared the directory /usr/local/apache2/htdocs/ to my Window’s computer using Samba. You can of course using others methods as your convenience. For another e.g. you may copy those data/files to a CD first, & then copy the data/files from that CD into the destination server. |
| v. |
Login to your Linux server by using telnet, ssh, or login directly from your Linux server instead. |
| vi. |
Let say, we have chosen the 3rd method and login as root or superuser. Then, we should continued in part(b) below. |
|
| (b) In my new computer - Running Linux Redhat: |
| i. |
Create a new database called MyDatabase. |
| ii. |
Running in system’s terminal. |
| iii. |
cp /usr/local/apache2/htdocs/MyDatabase/*.*
/usr/local/mysql/data/MyDatabase
- i.e. copy all those files within /usr/local/apache2/htdocs/MyDatabase to /usr/local/mysql/data/MyDatabase (i.e. the directory where my mysql data has been installed). |
| iv. |
chown mysql:mysql /usr/local/mysql/data/MyDatabase/*.*
- i.e change the ownership of the files to user->mysql and group->mysql. |
| v. |
chmod 660 /usr/local/mysql/data/MyDatabase/*.*
- i.e change the files permission to allow the user called mysql to perform the read and write operations. |
| vi. |
rm -fR /usr/local/apache2/htdocs/MyDatabase/
- i.e remove the directory MyDatabase within /usr/local/apache2/ |
|
| That’s all we need to do. I know there are simpler ways for us to migrate Mysql Data between different servers. Such as using PhpMyAdmin to export/import the data in an SQL text file and etc. But, such way will be tedious and troublesome when we tend to migrate a very large DB. |
| Hence, the alternative way I mentioned above may help you in migrating the large DB between servers. Of course, before you can using such an alternative way, you need to have some priveleges in those servers for accomplishing such tasks. And hope that it will be useful to anyone facing the same situation. |