How to profile MySQL

前端 未结 5 1103
猫巷女王i
猫巷女王i 2020-12-05 13:46

How do I profile a MySQL database. I want to see all the SQL being run against a database.

I know you can do this:

  • set profiling=1;
  • <
相关标签:
5条回答
  • 2020-12-05 14:01

    There is a commercial product

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

    0 讨论(0)
  • 2020-12-05 14:03

    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
    
    0 讨论(0)
  • 2020-12-05 14:10

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

    0 讨论(0)
  • 2020-12-05 14:14

    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

    0 讨论(0)
  • 2020-12-05 14:18

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

    0 讨论(0)
提交回复
热议问题