How to deploy MySQL and Redis services using Docker

How to deploy MySQL and Redis services using Docker

How to deploy MySQL service using Docker

1. Pull the latest version of MySQL 5.6

sudo docker pull mysql:5.6

2. View the MySQL image

sudo docker images

insert image description here

3. Create the directory that needs to be mapped under the home directory:

mkdir -p /home/computer/project/mysql/{conf,log,data}

4. Run the container

duso docker run -p 53603:3306 --name iot-mysql \ -v /home/computer/project/mysql/conf:/etc/mysql \ -v /home/computer/project/mysql/log:/var/log/mysql \ -v /home/computer/project/mysql/data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=pwd \ -d mysql:5.6

5. Configure MySQL remote connection

You need to enter the docker local client to set up a remote access account

View running containers

sudo docker ps

insert image description here

Enter the running container

sudo docker exec -it iot-mysql bash

# Operate mysql in the container -uroot -p123456
mysql> grant all privileges on *.* to root@'%' identified by "password";
select host,user,password from user;

# Change password update user set password=password("xxxxx") where user="root";
flush privileges;

6. More Docker Operations

sudo docker ps to view the running container
sudo docker ps -a View all containers
sudo docker stop 容器ID stops the container
sudo docker start 容器ID starts the container
sudo docker rm 容器ID delete container
sudo docker rmi 鏡像ID delete container

Let's look at how to deploy Redis service with Docker

1. Pull the latest version of redis image

sudo docker pull redis

2. View the Redis image

sudo docker images

insert image description here

3. Do not configure the data directory

sudo docker run -itd --name redis1 -p 53610:6379 redis --requirepass "psd"

4. Configure data directory

sudo docker run -itd --name redis1 -p 53610:6379 -v /home/computer/project/redis/data:/data --restart always redis --appendonly yes --requirepass "psd"

5. Parameter Description

-d -> Start the container as a daemon -p 53610:6379 -> Bind to the host port, 53610 host port, 6379 container port --name myredis -> Specify the container name --restart always -> Start at boot --privileged=true -> Increase permissions in the container --requirepass -> Set login password -v /root/docker/redis/data:/data -> Map data directory --appendonly yes -> Enable data persistence

6. More Docker Operations

insert image description here

sudo docker ps to view the running container
sudo docker ps -a View all containers
sudo docker stop 容器ID stops the container
sudo docker start 容器ID starts the container
sudo docker rm 容器ID delete container
sudo docker rmi 鏡像ID delete container

This is the end of this article about how to deploy MySQL and Redis services with Docker. For more information about deploying MySQL and Redis services with Docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker deploys mysql remote connection to solve 2003 problems
  • Implementation of docker-compose deployment project based on MySQL8
  • Example of how to deploy MySQL 8.0 using Docker
  • Implementation of Docker deployment of MySQL cluster
  • Detailed explanation of how to use Docker to deploy Django+MySQL8 development environment
  • Implementation of Docker deployment of Django+Mysql+Redis+Gunicorn+Nginx
  • Detailed explanation of deploying MySQL using Docker (data persistence)
  • Docker deploys mysql to achieve remote connection sample code
  • How to deploy MySQL 5.7 & 8.0 master-slave cluster using Docker
  • Alibaba Cloud ESC Server Docker Deployment of Single Node Mysql
  • Example of deploying MySQL on Docker

<<:  How to draw a mind map in a mini program

>>:  HTML is the central foundation for the development of WEB standards

Recommend

Detailed explanation of the workbench example in mysql

MySQL Workbench - Modeling and design tool 1. Mod...

About the processing of adaptive layout (using float and margin negative margin)

Adaptive layout is becoming more and more common i...

MySQL GTID comprehensive summary

Table of contents 01 Introduction to GTID 02 How ...

js handles account logout when closing the browser

Table of contents Classic approach question Furth...

A simple method to implement Linux timed log deletion

Introduction Linux is a system that can automatic...

An article teaches you JS function inheritance

Table of contents 1. Introduction: 2. Prototype c...

How to use VUE to call Ali Iconfont library online

Preface Many years ago, I was a newbie on the ser...

The difference between Input's size and maxlength attributes

I recently used the input size and maxlength attri...

Detailed explanation of Docker container data volumes

What is Let’s first look at the concept of Docker...

8 essential JavaScript code snippets for your project

Table of contents 1. Get the file extension 2. Co...

Docker file storage path, get container startup command operation

The container has already been created, how to kn...

52 SQL statements to teach you performance optimization

1. To optimize the query, try to avoid full table...

A brief discussion on JavaScript shallow copy and deep copy

Table of contents 1. Direct assignment 2. Shallow...