mysql 常見用法 mysql常見用法

2021-10-18 03:24:48 字數 666 閱讀 9563

檢視慢日誌

show variables like'%slow_query_log%';

show variables like'long_query_time%';設定慢日誌記錄什麼樣的sql,預設10s

log-queries-not-using-indexes:未使用索引的查詢也被記錄到慢查詢日誌中,一般也開啟這個變數

如果出現如下情況

mysql> show variables like '%slow_query_log%';

| variable_name | value |

| slow_query_log | off |

| slow_query_log_file | zhibingliu-slow.log |

2 rows in set

windows下my.ini新增

[mysqld]

slow-query-log=1

slow-query-log-file = "d:/xampp/mysql/data/mysql-slow.log"

long_query_time = 4 #預設為10秒

#min-examined-row-limit=30 #查詢檢查返回少於該引數指定行的sql不被記錄到慢查詢日誌

log-queries-not-using-indexes

mysql常見用法

1 常見命令 1.1 檢視所有賬戶資訊 select host,user from mysql.user select distinct concat user user,host,as query from mysql.user 1.2 修改賬戶密碼 use mysql update user s...

Mysql中Regexp常見用法

原文 查詢content欄位中包含 車友俱樂部 的記錄 select from club content where content regexp 車友俱樂部 此時的regexp與like的以下用法是等同的 select from club content where content like 車友...

mysql常問內容 mysql常問問題

前言 一些自己遇到的問題及理解 需補充修改 索引型別 主鍵索引 普通索引 符合索引 唯一索引 全文索引 索引 查詢資料的資料結構,索引占用磁碟空間,更新資料的時候影響更新表的效率 資料儲存型別 聚簇索引 非聚簇索引 聚簇 採用b 樹的資料結構,聚簇索引葉子節點存放證章表的資料,所以主鍵索引就是用的聚...