MariaDB: Using MariaDB CLIs (mysql, mysqldump, etc.)
This documentation is part of the Advanced usage guide. You can view the complete guide here: How to configure, optimise, export, or import MariaDB data.
👋 Welcome to Stackhero documentation
Stackhero offers a ready-to-use MariaDB cloud solution with a range of benefits, including:
- Unlimited connections and data transfers.
- Built-in phpMyAdmin web interface.
- One-click updates for simplified maintenance.
- Optimal performance and enhanced security thanks to private, dedicated infrastructure.
Save time and make your life easier: it takes just 5 minutes to try Stackhero's MariaDB cloud hosting solution!
MariaDB command-line tools such as mysql and mysqldump are essential for tasks like importing or exporting data.
Running these tools inside a Docker container simplifies setup, especially if you prefer not to install software directly on your computer.
If Docker is not part of your workflow, that is absolutely fine! You may wish to try Code-Hero on Stackhero instead. Code-Hero is a comprehensive development platform that runs directly in your browser, so there is no need for any local installation. Discover all its features and get started in just a few minutes by visiting Code-Hero on Stackhero.
To get started with Docker, you can launch a MariaDB container using the following command:
docker run -it -v $(pwd):/mnt mariadb:<MARIADB_VERSION> /bin/bash
Replace
<MARIADB_VERSION>with the specific MariaDB version you require. For example, if your application uses MariaDB version10.11.6-0on Stackhero, you can use version10.11.6(simply omit the-0suffix).
Once your container is running, you can check your connection with:
mysql -u root -p -h <XXXXXX>.stackhero-network.com -P <PORT>
When you start the container, your current directory is mounted to /mnt inside it (thanks to $(pwd):/mnt). This means any file in your current directory on your computer will be accessible in /mnt inside the container. For example, to back up a MariaDB database to your machine, run this command inside the container to save the backup as /mnt/<DATABASE>.sql:
mysqldump -u root -p -h <XXXXXX>.stackhero-network.com -P <PORT> <DATABASE> > /mnt/<DATABASE>.sql