Installing and using MariaDB 10.3 via Docker

Series: Docker

https://hub.docker.com/_/mariadb

Pulling and run image from command-line

docker run --name db -e MYSQL_ROOT_PASSWORD=YOUR_PASSWORD -e TZ=Asia/Seoul -p 3306:3306 -d mariadb:10.3 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
  • -e MYSQL_ROOT_PASSWORD=YOUR_PASSWORD
  • -e TZ=Asia/Seoul
  • -p 3306:3306
  • -d mariadb:10.3
  • –character-set-server=utf8mb4
  • –collation-server=utf8mb4_unicode_ci

Pulling and run image from docker-composer

docker-compose.yaml

version: '3'

services:
  db:
    image: mariadb:10.3
    container_name: db
    volumes:
      - /data/mariadb/datadir:/var/lib/mysql
      - /data/mariadb/conf.d:/etc/mysql/conf.d
    environment:
      - MYSQL_ROOT_PASSWORD=devplayg12!@
      - MYSQL_DATABASE=devplayg
      - MYSQL_USER=devplayg
      - MYSQL_PASSWORD=devplayg12!@
      - TZ=Asia/Seoul
    restart: unless-stopped
    ports:
      - "3306:3306"
    command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']

run

docker-compose up -d

connecting to database as “root”

docker exec -it db mysql -u root -p
  • password: root12!@

  • check user

    select host, user, password from mysql.user;
    
  • add another user

    create user 'devplayg'@'%' identified by 'devplayg12!@';
    grant all privileges on YOURDATABASE.* to 'devplayg'@'%';
    flush privileges;
    
Series: Docker
comments powered by Disqus