Docker安装Mariadb数据库 设置root密码 图文教程

前面我们介绍了Docker的内容:

下面我们记录一下如何安装Mariadb/MySQL数据库。

镜像库搜索安装Mariadb

搜索Mariadb

$ docker search mariadb
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mariadb MariaDB is a community-developed fork of MyS… 2848 [OK]
bitnami/mariadb Bitnami MariaDB Docker Image 98 [OK]
linuxserver/mariadb A Mariadb container, brought to you by Linux… 75
toughiq/mariadb-cluster Dockerized Automated MariaDB Galera Cluster … 38 [OK]
colinmollenhour/mariadb-galera-swarm MariaDb w/ Galera Cluster, DNS-based service… 26 [OK]
panubo/mariadb-galera MariaDB Galera Cluster 23 [OK]
lsioarmhf/mariadb ARMHF based Linuxserver.io image of mariadb 18
million12/mariadb MariaDB 10 – ~60Mb Alpine UTF-8 16 [OK]
webhippie/mariadb Docker images for MariaDB 15 [OK]
bianjp/mariadb-alpine Lightweight MariaDB docker image with Alpine… 9 [OK]
mariadb/server MariaDB Server is a modern database for mode… 9 [OK]
centos/mariadb-101-centos7 MariaDB 10.1 SQL database server 9
severalnines/mariadb A homogeneous MariaDB Galera Cluster image t… 7 [OK]
centos/mariadb-102-centos7 MariaDB 10.2 SQL database server 5
wodby/mariadb Alpine-based MariaDB container image with or… 4 [OK]
tutum/mariadb Base docker image to run a MariaDB database … 4
circleci/mariadb CircleCI images for MariaDB 3 [OK]
rightctrl/mariadb Mariadb with Galera support 2 [OK]
jonbaldie/mariadb Fast, simple, and lightweight MariaDB Docker… 2 [OK]
kitpages/mariadb-galera MariaDB with Galera 2 [OK]
tiredofit/mariadb-backup MariaDB Backup image to backup MariaDB/MySQL… 1 [OK]
demyx/mariadb FROM webhippie/mariadb:latest 0
jelastic/mariadb An image of the MariaDB SQL database server … 0
ansibleplaybookbundle/mariadb-apb An APB which deploys RHSCL MariaDB 0 [OK]
alvistack/mariadb Docker Image Packaging for MariaDB 0 [OK]

安装Mariadb

docker pull mariadb

运行 Mariadb 镜像

运行Mariadb服务

docker run --name jmariadb -p 3306:3306 -d -v D:\mysqlData:/var/lib/mysql  -e MYSQL_ROOT_PASSWORD=jiloc mariadb
  • -e MYSQL_ROOT_PASSWORD 设置数据库root密码 jiloc
  • -v 映射数据库文件位置
  • --name 设置容器别名

============以下是配置Mariadb的config文件映射============

查看容器ID

docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c63468060135 mariadb “docker-entrypoint.s…” 34 seconds ago Exited (1) 33 seconds ago jmariadb
c948b4856671 nginx “nginx -g ‘daemon of…” 21 minutes ago Up 20 minutes 0.0.0.0:8081->80/tcp jnginx
d593465ab743 bitnami/php-fpm “php-fpm -F –pid /o…” About an hour ago Up About an hour 9000/tcp jphp-fpm

创建配置文件夹/文件,挂载数据

创建 D:\DockerConfig\mysql ,我们将这个文件夹作为一会Docker将要映射的文件位置。

docker run -d -p 3306:3306 --name mariadb -v D:\DockerConfig\mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=jiloc mariadb

测试连接

docker ps -a
Docker安装Mariadb数据库 设置root密码 图文教程

确认数据库实例在运行,然后我们这里使用Navicat Premium 进行连接

Docker安装Mariadb数据库 设置root密码 图文教程
链接到文章: https://vpsum.com/45880.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注