MariaDB: Using MariaDB CLIs (mysql, mysqldump, etc.)

This documentation is part of the Advanced usage guide. View the full guide here: How to configure, optimize, export, or import MariaDB data.

👋 Welcome to Stackhero documentation

Stackhero provides a ready-to-use MariaDB cloud service designed for production workloads. You get:

  • Unlimited connections and data transfers.
  • Built-in phpMyAdmin web interface for database management.
  • One-click updates for easy maintenance.
  • High performance and strong security on private, dedicated infrastructure.

Launch a fully managed MariaDB instance in minutes. Stackhero handles setup, updates, and security so you can focus on your application. Learn more about MariaDB cloud hosting.

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 can simplify setup, especially if you want to avoid installing software directly on your computer.

If Docker is not part of your workflow, that is perfectly fine! You might want to try Code-Hero on Stackhero instead. Code-Hero is a full-featured development platform that runs right in your browser, so there is no need for local installations. You can learn more about its capabilities and get started in just a couple of minutes by visiting Code-Hero on Stackhero.

To get started with Docker, you can launch a MariaDB container using this command:

docker run -it -v $(pwd):/mnt mariadb:<MARIADB_VERSION> /bin/bash

Replace <MARIADB_VERSION> with the specific MariaDB version you need. If your application runs MariaDB version 10.11.6-0 on Stackhero, for example, you can use version 10.11.6 (just leave off the -0 suffix).

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 appear in /mnt inside the container. For example, if you want to back up a database from MariaDB to your machine, you can 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