How to install MySQL and MariaDB in Docker

How to install MySQL and MariaDB in Docker

Relationship between MySQL and MariaDB

MariaDB database management system is a branch of MySQL, mainly maintained by the open source community and licensed under the GPL.
MariaDB aims to be fully compatible with MySQL, including API and command line, making it an easy replacement for MySQL.

After reading about the relationship between MySQL and MariaDB, we must be wondering: since the two are so closely related, will there be any conflicts when they are installed and started at the same time?

The answer is yes, for example: `This article mainly explains the port number`. We will first look at the installation of both, and then during the configuration phase, differentiate MariaDB's port number from MySQL.

Install MySQL with Docker

Find the MySQL image on Docker Hub

docker search mysql

Select a mirror to install (here we choose centos/mysql-57-centos7)

docker pull centos/mysql-57-centos7

Start MySQL

docker run -p 3306:3306 --name mysql-57 -v /my/mysql/conf:/etc/mysql/conf.d -v /my/mysql/logs:/logs -v /my/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=xxx -d centos/mysql-57-centos7

Install MariaDB with Docker

Find the MariaDB image on Docker Hub

docker search mariadb

Select an image to install (here we choose the official image)

docker pull mariadb

Start MariaDB

docker run -v /my/mariadb/:/var/lib/mariadb -p 3309:3309 -e MYSQL_ROOT_PASSWORD=xxx --privileged=true --restart unless-stopped --name mariadbs -d mariadb:latest
Note: MariaDB starts on port 3309, and MySQL uses the default port 3306.

Startup completed, docker ps view

MariaDB port configuration

Although MariaDB starts using port 3309, we cannot access it remotely.

Enter the container directory

docker exec -it container id bash

Update the configuration file

vi /etc/mysql/my.cnf 

Restart

docker restart container id

Remotely connect and access again, normal!

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to install MySQL and Redis in Docker
  • Detailed steps for installing Tomcat, MySQL and Redis with Docker
  • How to install mysql in docker
  • Tutorial on installing MySQL with Docker and implementing remote connection
  • How to install MySQL 8.0 in Docker
  • Docker installation of MySQL (8 and 5.7)
  • How to install common components (mysql, redis) in Docker
  • How to install MySQL8 in Docker
  • Docker installation and configuration steps for MySQL

<<:  vue-cropper component realizes image cutting and uploading

>>:  How to change the MySQL database file directory in Ubuntu

Recommend

Guide to Efficient Use of MySQL Indexes

Preface I believe most people have used MySQL and...

MySQL initialization password operation under Mac

A simple record of the database startup problems ...

Detailed explanation of the basic use of Apache POI

Table of contents Basic Introduction Getting Star...

Research on Web Page Size

<br />According to statistics, the average s...

Detailed explanation of MySQL precompilation function

This article shares the MySQL precompilation func...

js code that associates the button with the enter key

Copy code The code is as follows: <html> &l...

Detailed explanation of VUE's data proxy and events

Table of contents Review of Object.defineProperty...

Don't forget to close the HTML tag

Building web pages that comply with Web standards ...

How to deploy SpringBoot project using Docker

The development of Docker technology provides a m...

About nginx to implement jira reverse proxy

Summary: Configure nginx reverse proxy jira and i...

A brief discussion on whether MySQL can have a function similar to Oracle's nvl

Use ifnull instead of isnull isnull is used to de...

How to write asynchronous tasks in modern JavaScript

Preface In this article, we'll explore the ev...

Docker network principles and detailed analysis of custom networks

Docker virtualizes a bridge on the host machine. ...

A simple example of how to implement fuzzy query in Vue

Preface The so-called fuzzy query is to provide q...