Database Reference
In-Depth Information
Then copy mail.sql to other-host.example.com , and run the following command there
to load the table into that MySQL server's other_db database:
% mysql other_db < mail.sql
To accomplish this without an intermediary file, use a pipe to send the output of mysql‐
dump directly over the network to the remote MySQL server. If you can connect to both
servers from your local host, use this command:
% mysqldump cookbook mail | mysql -h other-host.example.com other_db
The mysqldump half of the command connects to the local server and writes the dump
output to the pipe. The mysql half of the command connects to the remote MySQL
server on other-host.example.com . It reads the pipe for input and sends each statement
to the other-host.example.com server.
If you cannot connect directly to the remote server using mysql from your local host,
send the dump output into a pipe that uses ssh to invoke mysql remotely on other-
host.example.com :
% mysqldump cookbook mail | ssh other-host.example.com mysql other_db
ssh connects to other-host.example.com and launches mysql there. It then reads the
mysqldump output from the pipe and passes it to the remote mysql process. ssh can be
useful to send a dump over the network to a machine that has the MySQL port blocked
by a firewall but that permits connections on the SSH port.
Regarding which table or tables to copy, similar principles apply as for local copies. To
copy multiple tables over the network, name them all following the database argument
of the mysqldump command. To copy an entire database, don't specify any table names
after the database name; mysqldump dumps all its tables.
Search WWH ::




Custom Search