How to profile MySQL

一世执手 提交于 2019-11-27 21:08:26

You want the query log - but obviously doing this on a heavy production server could be... unwise.

Matija

That worked for me on Ubuntu.

Find and open your MySQL configuration file, usually /etc/mysql/my.cnf on Ubuntu. Look for the section that says “Logging and Replication”

# * Logging and Replication
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.

log = /var/log/mysql/mysql.log

or in newer versions of mysql, comment OUT this lines of codes

general_log_file        = /var/log/mysql/mysql.log
general_log             = 1
log_error                = /var/log/mysql/error.log

Just uncomment the log variable to turn on logging. Restart MySQL with this command:

sudo /etc/init.d/mysql restart

Now we’re ready to start monitoring the queries as they come in. Open up a new terminal and run this command to scroll the log file, adjusting the path if necessary.

tail -f /var/log/mysql/mysql.log

You can simply parse the query log in real time. If on linux, you can use tail -f to see the log live

Also, you can try some free software from these guys:

http://hackmysql.com/mysqlsla

Haim Evgi

There is a commercial product

http://www.webyog.com/en/

MySqlAdministrator have some useful build in features (including logs view), but for logs it have to be run on same machine as database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!