MariaDB is (mostly) a drop-in replacement for MySQL, so you can use the same tools and commands as you would with MySQL.
We use the official MariaDB image.
| Parameter | Value |
|---|---|
| Connection | Standard TCP/IP |
| Host | mysql (from a container)localhost (from your computer) |
| Port | 3306 |
| Username | root |
| Password | dbroot (this can be changed in .env) |
If you're looking for a suitable desktop app, we recommend TablePlus or MySQL Workbench.
See mysql/data/.
All database data is stored on your host machine (not inside the docker container). This makes it simple to update your Docker Dev environment without losing any data.
Warning: It is very easy to break your database if you touch any files in there. We recommend keeping SQL dumps of anything important.
We find it more convenient to use a GUI database application to export tables or full databases (like Table Plus), but if you wish, you can dump them from the command line like this:
# Run from the root folder of "docker-dev"
docker exec -i mysql mariadb-dump -u root -p DB_NAME > DB_NAME.dump.sqlThe command will prompt you for the root password (ie. dbroot).
If you wish to only export specific tables, list them after the database name like so:
docker exec -i mysql mariadb-dump -u root -p DB_NAME TABLE_A TABLE_B TABLE_C > DB_NAME.dump.sqlPrevention is always better than cure. We recommend keeping backups of anything important.
If you break the ownership permissions on MariaDB's "data" folder, try:
docker compose run mysql chown -R root:mysql /var/lib/mysql/*You can start from scratch by wiping the mysql/data/ folder:
- Stop all containers:
docker compose stop - Delete the
mysql/data/folder - Recreate the
mysql/data/folder - Start all containers:
docker compose up -d
The database's first boot will take longer than usual (ie. 30 seconds).
If you have previously used MariaDB then simply changing MYSQL_ROOT_PASSWORD in .env will not work. Instead, you will need to:
- Update
MYSQL_ROOT_PASSWORDin.env, to your new password - Build, start and exec into your MariaDB container:
docker compose exec mysql bash - Log into MariaDB using the old password:
mysql -u root -p - Execute the following:
use mysql;
update user set authentication_string=password('YOUR_NEW_PASSWORD_HERE') where user='root';
flush privileges;
quit;