You may quickly and easily backup MySQL using the mysqldump command. To generate a .sql file for an existing database, use this command. This command will build a basic .sql file of an existing database, which can then be restored to any other empty MySQL database. Regardless of whatever Linux distribution you use, this will work for you.
Using the following command, make a backup of the database:
mysqldump -u [username] –p[password] [database_name] > [your-dump-file.sql]
As detailed in the above command parameters, the specified command is as follows:
- [username] your MySQL username
- [password] - The user's valid MySQL password.
- [database name] - The name of the database you wish to back up.
- [your-dump-file.sql] The name of the backup dump file you wish to create.
Restore the backup to a local database server using the MySQL command. The command's syntax is:
mysql -u [username] –p[password] [database_name] < [your-dump-file.sql]
Restore the backup to a remote database server using the MySQL command. If you have the database credentials for another MySQL server, you may add the -h option to the command to provide a hostname. The command now looks:
mysql –h [hostname] –u [username] –p[password] [database_name] < [your-dump-file.sql]
You will be able to remotely restore the database if you have the correct data and the remote server is working.
Do you have any further questions? There is a way to communicate with our support staff through the Comment box.