Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sample code for docker deployment mysql to implement remote connections

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1.docker search mysql View mysql version

2.docker pull mysql should choose the name with the highest starts to download.

3.docker images to view the downloaded image

4. Start the mysql instance

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

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

-e MYSQL_ROOT_PASSWORD sets the mysql login password-d to run the daemon (running in the background) the last mysql is the image name

5. Docker ps-a view the running

6. Docker exec-it dockermysql bash enters the container. Dockermysql is the alias given to the container during the run time above, and can also be replaced by id.

7.docker mysql-u root-p and then enter the password directly, but the password is set at run time

Use mysql

8.grant all privileges on *. * to 'root'@'%'; used to grant permissions

GRANT ALL PRIVILEGES ON *. 'root'@'%' identified by' 123123 'WITH GRANT OPTION; this is a popular way of writing on the Internet. It's actually going to be wrong.

9.flush privileges; refresh permissions

10. Log in

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 version 8.0 from 5.7 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.

One of the methods is to 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 the user is granted permissions. If localhost, it's the same as above. % is the same.

New feature of mysql8.* caching_sha2_password password encryption

Previous versions of mysql password encryption used mysql_native_password

Caching_sha2_password used by default for newly added user passwords

If you upgrade on the basis of the previous mysql, you have to use mysql_native_password to encrypt the password.

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

Database time zone issues:

Problems with the parameter serverTimezone=UTC when linking to the database

Just change it to serverTimezone=Asia/Shanghai and it will be OK!

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report