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

Detailed tutorial on installing Ubuntu 19.10 on Raspberry Pi 4

Because some dependencies of opencv could not be ...

Zabbix monitors the process of Linux system services

Zabbix automatically discovers rules to monitor s...

Implementation of proxy_pass in nginx reverse proxy

The format is simple: proxy_pass URL; The URL inc...

How to change the website accessed by http to https in nginx

Table of contents 1. Background 2. Prerequisites ...

Summary of MySQL character sets

Table of contents Character Set Comparison Rules ...

Detailed explanation of keepAlive use cases in Vue

In development, it is often necessary to cache th...

Detailed explanation of webpack-dev-server core concepts and cases

webpack-dev-server core concepts Webpack's Co...

Summary of JavaScript's setTimeout() usage

Table of contents 1. Introduction 2. The differen...

centos7.2 offline installation mysql5.7.18.tar.gz

Because of network isolation, MySQL cannot be ins...

11 Examples of Advanced Usage of Input Elements in Web Forms

1. Cancel the dotted box when the button is press...

Analysis of HTTP interface testing process based on postman

I accidentally discovered a great artificial inte...

A preliminary understanding of CSS custom properties

Today, CSS preprocessors are the standard for web...

Example of Vue routing listening to dynamically load the same page

Table of contents Scenario Analysis Development S...