Skip to content

Database Management

Matteo Bilotta edited this page Oct 9, 2024 · 2 revisions

Back-ups

Warning

This page is under construction! ⚠

First of all, le'ts start the DB (if it isn't running yet):

docker compose up mariadb -d

Creating a back-up

From within your project's directory:

builder/run.sh backup-db --all > path/to/cmangos_$(date +"%Y-%m-%d_%H-%M-%S").tar.gz

Restoring a back-up

From within your project's directory:

builder/run.sh restore-db < path/to/cmangos-backup.tar.gz

Querying databases

To execute queries and -more generally- perform various operations on the databases, CMaNGOS Docker provides you both the graphical interface offered by phpMyAdmin and the CLI mysql command within the builder Docker container.
Choose the one that best suits your needs.

Use phpMyAdmin

phpMyAdmin is included in CMaNGOS Docker but is disabled by default.
To run it, you need to start it manually or specify the debug profile while typing the docker compose command.

If you want to start it manually:
docker compose up phpmyadmin
If you want to specify the debug profile:
docker compose --profile debug up

In either case, after running one of these commands, you'll be able to visit the page http://localhost:8080 and perform various operations on the databases with a rather intuitive graphical interface.

Use the builder Docker container

A Unix shell (e.g. bash)

Don't forget to replace the <database> placeholder with the name of the database you want to query.

# If you want to execute a single inline query

./builder/run.sh mysql -u root -p <database> -e "SELECT * FROM [...];"
# If you need to execute an entire `.sql` file

./builder/run.sh mysql -u root -p <database> < path/to/queries.sql
Windows Command Prompt (cmd.exe)

Don't forget to replace the <version> placeholder with the correct version of the client you want to support and the <database> placeholder with the name of the database you want to query.

REM If you want to execute a single inline query

docker run -it --rm ^
           --network "cmangos_default" ^
    ^
    ghcr.io/byloth/cmangos/<version>/builder:latest mysql -u root -p <database> -e "SELECT * FROM [...];"
REM If you need to execute an entire `.sql` file

docker run -it --rm ^
           --network "cmangos_default" ^
    ^
    ghcr.io/byloth/cmangos/<version>/builder:latest mysql -u root -p <database> < path/to/queries.sql
Windows PowerShell (powershell.exe)

Don't forget to replace the <version> placeholder with the correct version of the client you want to support and the <database> placeholder with the name of the database you want to query.

# If you want to execute a single inline query

docker run -it --rm `
           --network "cmangos_default" `
    `
    ghcr.io/byloth/cmangos/<version>/builder:latest mysql -u root -p <database> -e "SELECT * FROM [...];"
# If you need to execute an entire `.sql` file

docker run -it --rm `
           --network "cmangos_default" `
    `
    ghcr.io/byloth/cmangos/<version>/builder:latest mysql -u root -p <database> < path/to/queries.sql
Clone this wiki locally