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

User experience analysis of facebook dating website design

<br />Related article: Analysis of Facebook&...

JS ES6 asynchronous solution

Table of contents Initially using the callback fu...

How to quickly build an LNMP environment with Docker (latest)

Preface Tip: Here you can add the approximate con...

The principle and implementation of two-way binding in Vue2.x

Table of contents 1. Implementation process 2. Di...

File upload via HTML5 on mobile

Most of the time, plug-ins are used to upload fil...

Summary of MySQL database like statement wildcard fuzzy query

MySQL error: Parameter index out of range (1 >...

Two ways to remove the 30-second ad code from Youku video

I believe everyone has had this feeling: watching ...

Pure CSS to achieve left and right drag to change the layout size

Utilize the browser's non- overflow:auto elem...

How to configure anti-hotlinking for nginx website service (recommended)

1. Principle of Hotlinking 1.1 Web page preparati...

How to find websites with SQL injection (must read)

Method 1: Use Google advanced search, for example...

Complete steps for vue dynamic binding icons

0 Differences between icons and images Icons are ...

MySQL 8.0.22 installation and configuration graphic tutorial

MySQL8.0.22 installation and configuration (super...