Detailed explanation of using Docker to build externally accessible MySQL

Detailed explanation of using Docker to build externally accessible MySQL

Install MySQL 8.0

docker run -p 63306:3306 -e MYSQL_ROOT_PASSWORD=zhaooleemysql --name zhaooleemysqldb -d mysql:8.0
  • p 53306:3306 maps port 3306 of the docker container to port 63306 of the host machine
  • -e MYSQL_ROOT_PASSWORD=zhaooleemysql The root user login password is zhaooleemysql
  • --name zhaooleemysqldb The name of the new container is zhaooleemysqldb
  • mysql:8.0 The mysql database version used is 8.0

Entering the container

docker exec -it zhaooleemysqldb bash 

Login to database

mysql -uroot -p
zhaooleemysql

Create a new user (8.0 is more strict, it is troublesome to log in remotely with the root user, we choose to create a new user)

create user 'zhaoolee' identified with mysql_native_password by 'eelooahzpw';

zhaoolee new user name is zhaoolee. The mysql_native_password encryption method is mysql_native_password eelooahzpw new user's password is eelooahzpw

Add permissions for the new user zhaoolee

grant all privileges on *.* to 'zhaoolee';

Refresh permissions

flush privileges; 

Create a new database

create database v2fy charset=utf8;

The name of the new database is v2fy

Exit Database

exit

Exit Docker container

control + p + q

Try connecting with Navicat

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:
  • Detailed explanation of building a Mysql container + Tomcat container connection environment through Docker
  • Example of how to build a Mysql cluster with docker
  • The whole process of Docker building MySQL and mounting data

<<:  Detailed explanation of daily_routine example code in Linux

>>:  MySQL5.7.21 decompressed version installation detailed tutorial diagram

Recommend

Common usage of hook in react

Table of contents 1. What is a hook? 2. Why does ...

Explanation of factors affecting database performance in MySQL

A story about database performance During the int...

Apply provide and inject to refresh Vue page method

Table of contents Method 1: Call the function dir...

If I change a property randomly in Vue data, will the view be updated?

Interviewer: Have you read the source code of Vue...

Some basic instructions of docker

Table of contents Some basic instructions 1. Chec...

CSS3 realizes the animation of shuttle starry sky

Result: html <canvas id="starfield"&...

Use semantic tags to write your HTML compatible with IE6,7,8

HTML5 adds more semantic tags, such as header, fo...

A brief discussion on how to customize the host file in Docker

Table of contents 1. Command 2. docker-compose.ym...

MySQL database deletes duplicate data and only retains one method instance

1. Problem introduction Assume a scenario where a...

MySQL 5.7.23 decompression version installation tutorial with pictures and text

Download the MySQL installer Official download ad...

Centos8 bridge static IP configuration method in VMware virtual machine

1. Make sure the network connection method is bri...

Introduction to html form control disabled attributes readonly VS disabled

There are two ways to disable form submission in ...

HTML Tutorial: Collection of commonly used HTML tags (5)

Related articles: Beginners learn some HTML tags ...