1. Enter the container login account
docker to view the running container
docker ps
Copy after login
##Enter the container:
docker exec -it dc8880c13fef /bin/bash
Copy after login
Enter the username and password Log in to mysql
mysql -u root -p
Copy after login
and then enter the password to log in
2. View slow log related information
The slow log is turned off by default.
show variables like ‘slow%’; (or use, see other bloggers say there will be version differences, then use double percent signs: show variables like ‘%slow %’;)
Turn on the slow log switch
set global slow_query_log = ON;
Copy after login
was successfully turned on.
You can modify the threshold for judging whether it is slow SQL. When the SQL execution exceeds the threshold, it will be recorded in the slow log log file.
After modification, test select query.
Here we can see that the sql is recorded in the slow log.
The above is the detailed content of How to enable slow query log in docker mysql container. For more information, please follow other related articles on the PHP Chinese website!