- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to copy tables or databases from one MySQL server to another MySQL server?
152 Lectures 16 hours
87 Lectures 5.5 hours
If we want to copy tables or databases from one MySQL server to another, then use the mysqldump with database name and table name.
Run the following command at the source host. This will dump the complete database into dump.txt file.
$ mysqldump -u root -p database_name table_name > dump.txt password *****
We can copy complete database without using a particular table name as explained above.
Now, ftp dump.txt file on another host and use the following command. Before running this command, make sure we have created database_name on the destination server.
$ mysql -u root -p database_name < dump.txt password *****
Another way to accomplish this without using an intermediary file is to send the output of the MySQL dump directly over the network to the remote MySQL server. If we can connect to both the servers from the host where the source database resides, use the following command (Make sure we have access to both the servers).
$ mysqldump -u root -p database_name \ | mysql -h other-host.com database_name
In mysqldump, half of the command connects to the local server and writes the dump output to the pipe. The remaining half of the command connects to the remote MySQL server on the other-host.com. It reads the pipe for input and sends each statement to the other-host.com server.
- How to copy files from one server to another using Python?
- Copy from one column to another (different tables same database) in MySQL?
- How to GRANT SELECT ON all tables in all databases on a server with MySQL?
- How to copy a table from one MySQL database to another?
- How to copy rows from one table to another in MySQL?
- How to restart MySQL server?
- How to upgrade MySQL server from command line?
- MySQL Server and Server-Startup Programs
- Connecting to and Disconnecting from the MySQL Server
- How to copy data from one field to another on every row in MySQL?
- MySQL Server port number?
- mysqld - The MySQL Server
- MySQL query to copy records from one table to another with different columns
- Copying MySQL Databases to another Machine
- Which tables are used to control the privileges of MySQL database server?