# MariaDB Container Instance

# Create a new instance

  • Log into portainer https://[vm-ip]:9443
  • Make sure you've created a network of type bridge in portainer called mdb-management on the Networks page.
  • Navigate to the Stacks page and click on + Add stack
  • Name the instance and use the following docker-compose.yml definition.
    • You should change a few things here: hostnmane, host port and root password at least
# docker-compose.yml

version: '2.4'

services:
  db:
    image: mariadb:10.7.1
    restart: always
    ports:
      - 3306:3306                  # host:container
    hostname: mdb##                # change me
    environment:
      MYSQL_ROOT_PASSWORD: example # should be removed after initial install
    volumes:
      - data:/var/lib/mysql
    cpus: 0.5
    mem_limit: 1g
    memswap_limit: 0

volumes:
  data:

networks:
  default:
    external: true
    name: mdb-management

Note: You can create an App Template with the docker-compose file for later use

  • Click on Deploy the stack
  • You should remove the variable MYSQL_ROOT_PASSWORD after the initialization. See Change an existing instance for details.

# Change an existing instance

  • Log into portainer https://[vm-ip]:9443
  • Navigate to the Stacks page and click on the Stack you want to change
  • Click on the Editor-Tab and change the docker-compose.yml definition to you likings.
  • Click Update the stack and you are done

# Creating initial DB User and Database

Connect to the Database using Adminer or any other MySQL client of you choice.
Execute the following SQL Queries:

CREATE SCHEMA [DATABASE NAME];
CREATE USER [USER NAME];@'%' IDENTIFIED BY '[PASSWORD]';
GRANT ALL PRIVILEGES ON [DATABASE NAME].* to  [USER NAME]@'%';

Note: Replace the placeholders [DATABASE NAME], [USER NAME] and [PASSWORD]!

Page Info: Created by GitHub on Jun 9, 2023 (last updated a minute ago by GitHub)