If you are using MySQL 3.23 or later, you can copy the
.MYD files for
tables between different architectures that support the same
floating-point format. (MySQL takes care of any byte-swapping
issues.) See Section 13.1, “The
MyISAM Storage Engine”.
ISAM data and index files
respectively) are dependent upon the architecture and, in some
cases, the operating system. If you want to move applications to
another machine having a different architecture or operating
system than that of the current machine, you should not try to
move a database by simply copying the files to the other machine.
Use mysqldump instead.
Try mysqldump --help to see what options are
available. Before MySQL 4.1, if you are moving the data to a newer
version of MySQL, you should add the
--opt option to the
mysqldump commands shown here, to take
advantage of any optimizations that result in a dump file that is
smaller and can be processed faster.
--opt is enabled by default as
of MySQL 4.1.)
The easiest (although not the fastest) way to move a database between two machines is to run the following commands on the machine on which the database is located:
mysqladmin -h 'shell>
db_name| mysql -h '
If you want to copy a database from a remote machine over a slow network, you can use these commands:
mysqldump -h '
You can also store the dump in a file, transfer the file to the target machine, and then load the file into the database there. For example, you can dump a database to a compressed file on the source machine like this:
db_name| gzip >
Transfer the file containing the database contents to the target machine and run these commands there:
db_name.gz | mysql
You can also use mysqldump and
mysqlimport to transfer the database. For very
large tables, this is much faster than simply using
mysqldump. In the following commands,
DUMPDIR represents the full path name
of the directory you use to store the output from
First, create the directory for the output files and dump the database:
Then transfer the files in the
directory to a directory on the target machine and load the files
into MySQL there:
db_name# create database
DUMPDIR/*.sql | mysql
db_name# create tables in database
DUMPDIR/*.txt # load data into tables
Do not forget to copy the
because that is where the
host grant tables
are stored. You might have to run commands as the MySQL
root user on the new machine until you have the
mysql database in place.
After you import the
mysql database on the new
machine, execute mysqladmin flush-privileges so
that the server reloads the grant table information.