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

Implementation of Docker deployment of ElasticSearch and ElasticSearch-Head

This article mainly explains how to deploy Elasti...

Introduction to MySQL MHA operation status monitoring

Table of contents 1. Project Description 1.1 Back...

Some suggestions for ensuring MySQL data security

Data is the core asset of an enterprise and one o...

Detailed explanation of client configuration for vue3+electron12+dll development

Table of contents Modify the repository source st...

How to add fields to a large data table in MySQL

Preface I believe everyone is familiar with addin...

Docker deploys mysql remote connection to solve 2003 problems

Connecting to MySQL Here I use navicat to connect...

Linux uses stty to display and modify terminal line settings

Sttty is a common command for changing and printi...

Summary of various methods of MySQL data recovery

Table of contents 1. Introduction 2. Direct recov...

How to view nginx configuration file path and resource file path

View the nginx configuration file path Through ng...

Problems and pitfalls of installing Mysql5.7.23 in Win10 environment

I read many tutorials, but found that I could nev...

How to limit the number of concurrent connection requests in nginx

Introduction The module that limits the number of...

Steps to set up HTTPS website based on Nginx

Table of contents Preface: Encryption algorithm: ...

js implements the algorithm for specifying the order and amount of red envelopes

This article shares the specific code of js to im...

How to add vector icons to web font files in web page production

As we all know, there are two types of images in c...