By Sophia | Last Updated
Do you want to upgrade your server? You might think it is a difficult thing to migrate the old server database include configuration information and user profiles to a new server without data loss. Actually, copying MySQL database from one server to another requires only four steps in total.
The following tutorial will show you how to export MySQL database from the old server, safeguard it, copy and import it to the new server then make sure it is there.
Notes
The Oracle built-in tool called mysqldump allows users to export database to a dump file. Before running the command, please replace the [database name] with your own name.
mysqldump -u root -p --opt [database name][database name].sql
Now your dump file is performed.
To prevent your database from attack from the virus, we can use the zip command to secure it.
zip --encrypt dump.zip db.sql
Type your password when a prompt show you. Then you can see the dump file is encrypted.
The SCP can help you transfer the encrypted dump file to the new server.
scp /path/to/source-file user@host:/path/to/destination-folder/
To unencrypt and extract the dump file, run this command:
unzip -P your-password dump.zip
After extract the file, you can import to the new server:
mysql -u root -p newdatabase < /path/to/newdatabase.sql
Related Articles: