Docker deploys mysql to achieve remote connection sample code

Docker deploys mysql to achieve remote connection sample code

1.docker search mysql查看mysql版本

2. docker pull mysql要選擇starts最高的那個name 進行下載

3. docker images查看下載好的鏡像

4. Start the MySQL instance

 docker run --name dockermysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql

--name sets an alias for the mysql instance. -p 3307 is the port exposed to the outside. 3306 is the internal port

-e MYSQL_ROOT_PASSWORD sets the mysql login password -d runs as a daemon (background run) The last mysql is the image name

5. docker ps -a查看在運行的

6. docker exec -it dockermysql bash進入容器內部 dockermysql 是上邊運行時為容器取的別名也可以用id替代

7.docker mysql -u root -p然后直接輸入密碼即可密碼是在運行時設置的

use mysql

8. grant all給用于授予權限grant permissions

GRANT ALL PRIVILEGES ON *.* 'root'@'%' identified by '123123' WITH GRANT OPTION; This is a more common way of writing on the Internet. In fact, it will report an error.

9.flush privileges; refresh privileges

10. Login

11.Mysql remote connection error: authentication plugin caching_sha2

MySQL 8.0 uses the caching_sha2_password authentication mechanism by default - changing from mysql_native_password to caching_sha2_password.

Upgrading from 5.7 to 8.0 will not change the authentication method for existing users, but new users will use the new caching_sha2_password by default.

The client does not support the new encryption method.

Method 1: Change the user's password and encryption method

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';

It should be the same as when granting user permissions. If it is localhost, do the same as above. The same is true for %

New feature of mysql8.*: caching_sha2_password password encryption method

Previous versions of MySQL used mysql_native_password for password encryption.

The default caching_sha2_password for newly added user passwords is

If you upgrade based on the previous MySQL, the password encryption used by the user must be mysql_native_password

If you use the previous password encryption method, modify the file /etc/my.cnf

Database time zone problem:

Problem with the parameter serverTimezone=UTC when connecting to the database

Just change it to serverTimezone=Asia/Shanghai and you’ll be fine!

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:
  • Docker enables secure TLS remote connection access
  • How to set up vscode remote connection to server docker container
  • Docker deploys mysql remote connection to solve 2003 problems
  • Detailed example of remotely connecting to Docker using TLS encrypted communication
  • Tutorial on installing MySQL with Docker and implementing remote connection
  • Detailed explanation of docker daemon remote connection settings
  • Implementation example of Docker remote connection settings

<<:  MAC+PyCharm+Flask+Vue.js build system

>>:  MySQL server 5.7.20 installation and configuration method graphic tutorial

Recommend

ElementUI component el-dropdown (pitfall)

Select and change: click to display the current v...

Using Zabbix to monitor the operation process of Oracle table space

0. Overview Zabbix is ​​an extremely powerful ope...

How does the composite index of MySQL take effect?

Table of contents background Understanding compos...

Vue+Element UI realizes the encapsulation of drop-down menu

This article example shares the specific code of ...

Summary of HTML knowledge points for the front end (recommended)

1. HTML Overview htyper text markup language Hype...

How to find out uncommitted transaction information in MySQL

A while ago, I wrote a blog post titled "Can...

Summary of the unknown usage of "!" in Linux

Preface In fact, the humble "!" has man...

MYSQL slow query and log settings and testing

1. Introduction By enabling the slow query log, M...

A brief analysis of whether using iframe to call a page will cache the page

Recently, I have a project that requires using ifr...

Descending Index in MySQL 8.0

Preface I believe everyone knows that indexes are...

MySQL concurrency control principle knowledge points

Mysql is a mainstream open source relational data...

Detailed description of the life cycle of React components

Table of contents 1. What is the life cycle 2. Lo...

Understanding MySQL Locking Based on Update SQL Statements

Preface MySQL database lock is an important means...