1. Pull the image
docker pull mysql:8.0.28
2. Start the container
docker run -d --name mysql -p 23306:3306 -e MYSQL_ROOT_PASSWORD=Abcd@2023! mysql:8.0.28 --lower_case_table_names=1
3. Change password (backup)
-
into the container
docker exec -it mysql bash
-
authentication
mysql -uroot -p123456 use mysql
-
change Password
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '新密码'
-
Refresh permissions
flush privileges
4. Synchronize time
docker cp /usr/share/zoneinfo/Asia/Shanghai mysql:/etc/localtime
5. Too Many Connections
SHOW VARIABLES LIKE 'max_connections';
SET GLOBAL max_connections=1000;
SET GLOBAL wait_timeout=300;