How to: Transfer MySQL database from one server to another UNIX / Linux server

‮al.www‬utturi.com
How to: Transfer MySQL database from one server to another UNIX / Linux server

To transfer a MySQL database from one server to another on a UNIX or Linux system, you can use the following steps:

  1. On the source server, use the mysqldump command to create a backup of the database. This will create a file containing the SQL statements needed to recreate the database and its contents. For example:
mysqldump -u username -p database_name > database_name.sql

Replace "username" with your MySQL username and "database_name" with the name of the database you want to transfer. You will be prompted to enter your password when you run the command.

  1. Transfer the SQL file to the destination server. You can use a tool such as scp to securely copy the file from the source server to the destination server. For example:
scp database_name.sql username@destination_server:/path/to/destination
  1. On the destination server, create a new database to import the data into. You can do this using the mysql command-line tool. For example:
mysql -u username -p

Enter your password when prompted. Then, run the following command to create a new database:

CREATE DATABASE database_name;
  1. Use the mysql command to import the data from the SQL file into the new database. For example:
mysql -u username -p database_name < database_name.sql

Enter your password when prompted. This will execute the SQL statements in the file and recreate the database and its contents on the destination server.

Note: These steps assume that you have access to the MySQL server on both the source and destination servers and that you have the necessary permissions to create and modify databases.

Created Time:2017-10-29 22:08:42  Author:lautturi