4個MySQL 資料庫基本除錯技巧

4個MySQL 資料庫基本除錯技巧

 

1. 資料庫日誌error.log

/var/log/mysql / error.log

/var/ lib/mysql / error.log

120714 15:35:26 [Note] Plugin 'FEDERATED' is disabled.
120714 15:35:26 InnoDB: Initializing buffer pool, size = 8.0M
120714 15:35:26 InnoDB: Completed initialization of buffer pool
120714 15:35:26 InnoDB: Started; log sequence number 0 67138180
120714 15:35:27 [Note] Event Scheduler: Loaded 0 events
120714 15:35:27 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.63-0ubuntu0.10.04.1-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306
Ê(Ubuntu)

 

2. 資料庫執行狀態

 

 

$ sudo service mysql status

mysql start/running, process 735

 

 

$ ps -ef | grep mysql

mysql 735 1 0 Jun12  02:02:56 /usr/sbin/mysqld

 

$ sudo netstat -lnp | grep :3306

tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 735/mysqld

 

3. 資料庫執行數據

 

 

mysqladmin -u root -p status



Uptime: 2680987 Threads: 1 Questions: 17494181 Slow queries: 0 Opens: 2096 Flush tables: 1 Open tables: 64 Queries per second avg: 6.525

 

Queries per second avg:  The average number of queries per second the database receives

Slow queries: The number of queries that have taken more than long_query_time seconds

 

$ mysqladmin -u root -p extended-status

 

4. 執行時間過長的 Query

 

 

 

# Define in my.cnf

log_slow_queries = /var/log/mysql/mysql-slow.log

long_query_time = 2

 

$ mysqladmin -u root -p processlist

 

 

 

Leave a Reply

Your email address will not be published.