MySQL: Using MySQL command-line tools (mysql, mysqldump, etc.)
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.
MySQL command-line tools like mysql and mysqldump are very useful for tasks such as importing and exporting data.
One easy way to access these tools is by running them inside a Docker container. This approach keeps your local setup clean and avoids the need for manual installations.
If Docker is not part of your workflow, this is absolutely fine. You might want to check out Code-Hero on Stackhero. This browser-based development platform lets you work directly in your browser, so you do not need to install anything locally. You can learn more and try it out in just a couple of minutes by visiting Code-Hero on Stackhero.
To get started with Docker, you can spin up a MySQL container by running:
docker run -it -v $(pwd):/mnt mysql:<MYSQL_VERSION> /bin/bash
Replace
<MYSQL_VERSION>with the version you need. For example, if you are running MySQL8.0.36-0on Stackhero, use8.0.36(leave off the-0at the end).
Once your container is running, you can test your connection with this command:
mysql -u root -p -h <XXXXXX>.stackhero-network.com -P <PORT>
Here, your current directory is mounted to /mnt inside the container (thanks to the $(pwd):/mnt argument). This setup makes it easy to move files between your computer and the container. For example, if you would like to back up a database to your machine, you can use:
mysqldump -u root -p -h <XXXXXX>.stackhero-network.com -P <PORT> <DATABASE> > /mnt/<DATABASE>.sql