|
4 | 4 |
|
5 | 5 | ## About
|
6 | 6 |
|
7 |
| -MariaDB is a fork of MySQL. This is an unofficial image provided by linuxserver.io because there is no official image for arm |
| 7 | +MariaDB is a fork of MySQL. This is an unofficial image provided by linuxserver.io because there is no official image for arm. |
8 | 8 |
|
9 |
| -## Conneting to the DB |
| 9 | +## Connecting to the DB |
10 | 10 |
|
11 | 11 | The port is 3306. It exists inside the docker network so you can connect via `mariadb:3306` for internal connections. For external connections use `<your Pis IP>:3306`
|
12 | 12 |
|
13 | 13 | 
|
14 | 14 |
|
15 | 15 | ## Setup
|
16 | 16 |
|
17 |
| -Before starting the stack edit the `./services/mariadb/mariadb.env` file and set your access details. This is optional however you will only have one shot at the preconfig. If you start the container without setting the passwords then you will have to either delete its volume directory or enter the terminal and change manually |
| 17 | +Before starting the stack, edit the `docker-compose.yml` file and check your environment variables. In particular: |
18 | 18 |
|
19 |
| -The env file has three commented fields for credentials, either **all three** must be commented or un-commented. You can't have only one or two, its all or nothing. |
| 19 | +``` |
| 20 | + environment: |
| 21 | + - TZ=Etc/UTC |
| 22 | + - MYSQL_ROOT_PASSWORD= |
| 23 | + - MYSQL_DATABASE=default |
| 24 | + - MYSQL_USER=mariadbuser |
| 25 | + - MYSQL_PASSWORD= |
| 26 | +``` |
| 27 | + |
| 28 | +If you are running old-menu, you will have to set both passwords. Under new-menu, the menu may have allocated random passwords for you but you can change them if you like. |
| 29 | + |
| 30 | +You only get the opportunity to change the `MQSL_` prefixed environment variables before you bring up the container for the first time. If you decide to change these values after initialisation, you will either have to: |
| 31 | + |
| 32 | +1. Erase the persistent storage area and start again. There are three steps: |
| 33 | + |
| 34 | + * Stop the container and remove the persistent storage area: |
| 35 | + |
| 36 | + ``` |
| 37 | + $ cd ~/IOTstack |
| 38 | + $ docker-compose rm --force --stop -v mariadb |
| 39 | + $ sudo rm -rf ./volumes/mariadb |
| 40 | + ``` |
| 41 | + |
| 42 | + * Edit `docker-compose.yml` and change the variables. |
| 43 | + * Bring up the container: |
| 44 | + |
| 45 | + ``` |
| 46 | + $ docker-compose up -d mariadb |
| 47 | + ``` |
| 48 | + |
| 49 | +2. Open a terminal window within the container (see below) and change the values by hand. |
| 50 | + |
| 51 | + > The how-to is beyond the scope of this documentation. Google is your friend! |
20 | 52 |
|
21 | 53 | ## Terminal
|
22 | 54 |
|
23 |
| -A terminal is provided to access mariadb by the cli. execute `./services/mariadb/terminal.sh`. You will need to run `mysql -uroot -p` to enter mariadbs interface |
| 55 | +You can open a terminal session within the mariadb container via: |
| 56 | + |
| 57 | +``` |
| 58 | +$ docker exec -it mariadb bash |
| 59 | +``` |
| 60 | + |
| 61 | +To close the terminal session, either: |
| 62 | + |
| 63 | +* type "exit" and press <kbd>return</kbd>; or |
| 64 | +* press <kbd>control</kbd>+<kbd>d</kbd>. |
| 65 | + |
| 66 | +## Keeping MariaDB up-to-date |
| 67 | + |
| 68 | +To update the `mariadb` container: |
| 69 | + |
| 70 | +``` |
| 71 | +$ cd ~/IOTstack |
| 72 | +$ docker-compose build --no-cache --pull mariadb |
| 73 | +$ docker-compose up -d mariadb |
| 74 | +$ docker system prune |
| 75 | +$ docker system prune |
| 76 | +``` |
| 77 | + |
| 78 | +The first "prune" removes the old *local* image, the second removes the old *base* image. |
0 commit comments