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

Implementation of Docker container connection and communication

Port mapping is not the only way to connect Docke...

MySQL master-slave configuration study notes

● I was planning to buy some cloud data to provid...

Pure CSS to achieve click to expand and read the full text function

Note When developing an article display list inte...

Detailed explanation of Mysql transaction processing

1. MySQL transaction concept MySQL transactions a...

Realizing tree-shaped secondary tables based on angular

First look at the effect: Code: 1.html <div cl...

Introducing icons by implementing custom components based on Vue

Preface In project development, there are many wa...

Web page text design should be like smart girls wearing clothes

<br />"There are no ugly women in the w...

Windows 2016 Server Security Settings

Table of contents System update configuration Cha...

A brief analysis of the basic implementation of Vue detection data changes

Table of contents 1. Object change detection 2. Q...

Vue element implements table adding, deleting and modifying data

This article shares the specific code of vue elem...

Solve the error problem caused by modifying mysql data_dir

Today, I set up a newly purchased Alibaba Cloud E...

vue3 custom directive details

Table of contents 1. Registering custom instructi...

Tutorial on Migrating Projects from MYSQL to MARIADB

Prepare the database (MySQL). If you already have...