How to install MySQL 8.0 in Docker

How to install MySQL 8.0 in Docker
Environment: MacOS_Cetalina_10.15.1, Mysql8.0.18, Docker_2.0.0.3

1. Search mysql in docker repository

docker search mysql 

2. Pull mysql8.0 from the docker repository

docker pull mysql:8.0
Remark:
docker pull mysql //Pull the latest version by default 

3. Check whether the local warehouse image is downloaded successfully

docker images mysql:8.0 

4. Install and run the mysql8.0 container

docker run -p 3307:3306 --name mysql8.0 -e MYSQL_ROOT_PASSWORD=root -d mysql:8.0
Remark:
-p maps the local host port to the docker container port (because the local port 3306 is already occupied by other versions, use 3307)
--name container name -e configuration information, configure root password -d image name 

5. Check the running status of mysql8.0 container

docker ps 

6. Docker logs in to MySQL

docker exec -it mysql8.0 bash
mysql -uroot -p 

7. Use the client connection tool (navicat) to remotely log in to MySQL

I found that I couldn't log in. The error message was: Navicat does not support the caching_sha_password encryption method. Reason: MySQL 8.0 uses a new password encryption method: caching_sha_password
Solution: Change to the old encryption method (mysql_native_password) and reset the password
* select host,user,plugin from user;
* alter user 'root'@'%' identified with mysql_native_password by 'root';

8. Use the client connection tool (navicat) to remotely log in to MySQL again

9. Postscript (commonly used docker commands)

docker search image name //Search for imagesdocker pull image name: version number //Pull the image of the corresponding versiondocker pull image name //Pull the latest image by defaultdocker images //View the locally downloaded imagesdocker ps //View the running containersdocker ps -a //View all containers (including those in run, stop, and exited states)
docker container ls //View running containersdocker rm container ID //Only delete containers that are not runningdocker rm -f container ID //Can delete running containersdocker run -p local host port number: container service port number--name container name[-e configuration information modification] -d image namedocker start container ID //Start containerdocker stop container ID //Terminate containerdocker rmi image name orID //Delete image

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:
  • Methods for deploying MySQL services in Docker and the pitfalls encountered
  • Detailed explanation of using MySQL database in docker (access in LAN)
  • Solution to failure in connecting to mysql in docker
  • Detailed explanation of importing/exporting MySQL data in Docker container
  • Install and run a MySQL instance on Docker
  • A practical record of a docker login mysql error problem

<<:  Use of Linux network configuration tools

>>:  Detailed code for implementing 3D tag cloud in Vue

Recommend

Summary of several common methods of JavaScript arrays

Table of contents 1. Introduction 2. filter() 3. ...

Coexistence of python2 and python3 under centos7 system

The first step is to check the version number and...

Good website copywriting and good user experience

Looking at a website is actually like evaluating a...

Convert XHTML CSS pages to printer pages

In the past, creating a printer-friendly version ...

The latest collection of 18 green style web design works

Toy Story 3 Online Marketing Website Zen Mobile I...

Detailed analysis of several situations in which MySQL indexes fail

1. Leading fuzzy query cannot use index (like ...

MySql development of automatic synchronization table structure

Development Pain Points During the development pr...

How to view the execution time of SQL statements in MySQL

Table of contents 1. Initial SQL Preparation 2. M...

The corresponding attributes and usage of XHTML tags in CSS

When I first started designing web pages using XH...

Analysis of the method of setting up scheduled tasks in mysql

This article uses an example to describe how to s...

CocosCreator learning modular script

Cocos Creator modular script Cocos Creator allows...

Specific use of routing guards in Vue

Table of contents 1. Global Guard 1.1 Global fron...

Summary of common docker commands (recommended)

1. Summary: In general, they can be divided into ...

Copy the contents of one file to the end of another file in linux

Problem description: For example, the content of ...