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 fully managed MySQL cloud service that streamlines deployment and management for your production workloads:

  • Unlimited connections and data transfers.
  • Integrated phpMyAdmin web interface for simplified database management.
  • Effortless updates with one-click upgrades.
  • Consistent performance and enhanced security on a private, dedicated infrastructure.

With Stackhero, you get a reliable MySQL database ready in just a few minutes. Spend less time on setup and maintenance, and focus on developing your applications. Try MySQL cloud hosting on Stackhero today.

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.)

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.

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.