MySQL: Dumping a MySQL database
This documentation is part of the Advanced usage guide. View the full guide here: How to configure, optimize, export, or import MySQL data.
👋 Welcome to the Stackhero documentation!
Stackhero provides a fully managed MySQL cloud service that simplifies deployment and management for production workloads:
- Unlimited connections and data transfers.
- Integrated phpMyAdmin web interface for easy database management.
- Hassle-free updates with one-click upgrades.
- Consistent performance and strong security on a private, dedicated infrastructure.
With Stackhero, you can have a reliable MySQL database ready in just a few minutes. Spend less time on setup and maintenance, and more time building your applications. Try MySQL cloud hosting on Stackhero today.
To create a database backup (or "dump"), you can use the mysqldump tool directly from your computer. (See the previous section for details on 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, you can run:
mysqldump -u root -p -h <XXXXXX>.stackhero-network.com -P <PORT> <DATABASE> > <DATABASE>.sql
Make sure to replace <XXXXXX>.stackhero-network.com, <PORT>, and <DATABASE> with your actual instance details. After you run 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, you can use this command:
mysql -u root -p -h <XXXXXX>.stackhero-network.com -P <PORT> <DATABASE> < yourDump.sql
Just remember to replace yourDump.sql with the actual filename for the SQL file you want to import.