MySQL: Backing up a MySQL database
This documentation is part of the Advanced usage guide. You can view the complete guide here: How to configure, optimize, export, or import MySQL data.
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use MySQL cloud solution that provides a host of benefits, including:
- Unlimited connections and transfers.
- phpMyAdmin web UI included.
- Effortless updates with just a click.
- Optimal performance and robust security powered by a private and dedicated VM.
Save time and simplify your life: it only takes 5 minutes to try Stackhero's MySQL cloud hosting solution!
To create a backup (or "dump") of your database, you can use the mysqldump tool directly from your computer. (Refer to the previous section for running it inside Docker if you prefer.)
Exporting a MySQL database to your computer
To export a database from your Stackhero instance to your computer, run:
mysqldump -u root -p -h <XXXXXX>.stackhero-network.com -P <PORT> <DATABASE> > <DATABASE>.sql
Be sure to replace <XXXXXX>.stackhero-network.com, <PORT>, and <DATABASE> with your actual instance details. After running the command, you will be prompted for the root password. The mysqldump tool will then save your database tables in a file named <DATABASE>.sql.
Importing a MySQL database to your server
To import a database from your computer into your Stackhero instance, use the following command:
mysql -u root -p -h <XXXXXX>.stackhero-network.com -P <PORT> <DATABASE> < yourDump.sql
Don't forget to replace yourDump.sql with the actual filename of the SQL file you want to import.