当前位置:网站首页>docker mysql容器如何开启慢查询日志
docker mysql容器如何开启慢查询日志
2022-07-15 18:15:00 【phpstory】
一、查看所有容器
docker ps
二、进入容器
docker exec -it mysql容器ID或者容器名称 /bin/bash
三、输入用户名密码登陆mysql
mysql -u root -p
输入密码
set global slow_query_log = ON;
可以修改判断是否为慢sql的阈值,sql执行超过阈值的时候就会记录到慢日志的log文件中。
set global slow_launch_time = 3;//根据自己个的需要设置秒数
修改完毕,进行测试select 查询。
四、退出容器,查看慢查询日志
cat /var/lib/mysql/a8960d73be2c-slow.log

详情参考 https://www.jb51.net/article/241552.htm
五、永久开启(数据库服务重启后不失效)
修改配置文件my.cnf,在[mysqld]下的下方加入
[mysqld]
slow_query_log = ON
slow_query_log_file = /var/lib/mysql/tmp_slow.log //linux
long_query_time = 1
然后重启mysql服务。
参考:https://blog.csdn.net/keketrtr/article/details/95636815
边栏推荐
- Common differences between MySQL and Oracle (I)
- Software architecture and design (x) -- Architecture Technology
- DNS攻击防护原理
- Common methods of golang net network package
- “企业数字化转型”十大案例!
- 數百億數據壓縮至 600GB,TDengine 落地協鑫能科移動能源平臺
- C# Channel 简单实现消息队列的发布、订阅
- Daily question 1: the minimum value of the sum of the largest number pairs in the array (leecode)
- How to set the allure test report
- VxWorks环境搭建与学习
猜你喜欢

事件4624是登录成功!?!真的如此吗?

【每日一题】558. 四叉树交集

i. Mx6ull driver development | 30 - use EC20 4G network card (migrate gobinet driver)

#夏日挑战赛# HarmonyOS 实现一个手绘板

OpenCV 教程 01:简介与安装,图片与视频的基本操作

Li Mu hands on deep learning V2 target detection data set

JVM memory scaling

How to set the allure test report

Vscode default new directory overlap

Torch in pytoch Repeat() function parsing
随机推荐
Meituan side: why does thread crash not cause JVM crash?
Torch in pytoch Unsqueeze() and torch Squeeze() function parsing
一文搞懂Go整合captcha实现验证码功能
Several common methods of database table query in SAP ABAP system
开发命令行工具
《MySQL高级篇》二、逻辑架构分析
STL值string学习
Torch in pytoch Argmax() function parsing
Meituan side: @transactional principle and common pits?
VxWorks environment construction and learning
Tens of billions of data were compressed to 600gb, and tdengine was launched on GCL energy mobile energy platform
Qt(二)UI控件简介与 可选树状控件演示
i.MX6ULL驱动开发 | 30 - 使用EC20 4G网卡(移植移远GobiNet驱动)
Is it safe for tongdaxin to open an account? Which securities are good for opening an account
clickhouse 20.x 分布式表测试与chproxy的部署(二)
Vscode default new directory overlap
在 SQL Server 中查找活动的 SQL 连接
Torch in pytoch Sort() and torch Argsort() function parsing
Is it safe to open an account online now? Want to know which are the top ten securities dealers in China?
Go1.18 upgrade function - fuzzy test | go language from scratch