1.docker search mysql Check mysql version
Select the name with the highest starts to download
View the downloaded image
docker run --name dockermysql -p 3307:3306 -e mysql_root_password=my-secret-pw -d mysql
--name Set an alias for the mysql instance. -p 3307 is the port exposed to the outside world. 3306 is the internal port
-e mysql_root_password Set mysql login password -d Run as a daemon process (run in the background) The last mysql is the image name
View the running
##6. docker exec -it dockermysql bash
Enter the container dockermysql is the alias given to the container when running above You can also use id instead 7.docker mysql -u root -p
use mysql
8.grant all privileges on *.* to 'root'@'%' ;
Grant permissions grant all privileges on *.* 'root'@'%' identified by '123123' with grant option; This is a writing method that is widely circulated on the Internet. In fact, an error will be reported.
9.flush privileges; Refresh privileges
10.Login
11.mysql remote connection error:
authentication plugin caching_sha2mysql 8.0 uses the caching_sha2_password authentication mechanism by default - changed from the original mysql_native_password to caching_sha2_password.
Upgrading from 5.7 to version 8.0 will not change the authentication method of existing users, but new users will use the new caching_sha2_password by default.
The client does not support the new encryption method.
One of the methods is to modify the user's password and encryption method
alter user 'root'@'%' identified with mysql_native_password by 'password';
must be assigned to the same user permissions are the same. If it is localhost, the same as above. The same is true for %
mysql8.*’s new feature caching_sha2_password password encryption method
The previous version of mysql password encryption used
mysql_native_password
The default password for newly added users is
If you upgrade based on the previous mysql, the password encryption used by the user must use mysql_native_password
If you use the previous password encryption method, modify the file /etc/my.cnf
Database time zone problem:
Problems with the servertimezone=utc parameter when linking to the database
Just change it to servertimezone=asia/shanghai and it will be ok!
The above is the detailed content of How docker deploys mysql to achieve remote connection. For more information, please follow other related articles on the PHP Chinese website!