Skip to content

Latest commit

 

History

History
62 lines (39 loc) · 1.98 KB

mariadb-database.md

File metadata and controls

62 lines (39 loc) · 1.98 KB

MariaDB

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.

Connecting

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.

Where is my data stored?

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.

Database is corrupt

Prevention 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:

  1. Stop all containers: docker compose stop
  2. Delete the mysql/data/ folder
  3. Recreate the mysql/data/ folder
  4. Start all containers: docker compose up -d

Changing the root password

If you have previously used MariaDB then simply changing MYSQL_ROOT_PASSWORD in .env will not work. Instead, you will need to:

  1. Update MYSQL_ROOT_PASSWORD in .env, to your new password
  2. Build, start and exec into your MariaDB container: docker compose exec mysql bash
  3. Log into MariaDB using the old password: mysql -u root -p
  4. Execute the following:
use mysql;
update user set authentication_string=password('YOUR_NEW_PASSWORD_HERE') where user='root';
flush privileges;
quit;