Mysql LOG

Como ativar Tracelog no mysql

#Verifica o caminho do log
SHOW VARIABLES LIKE “general_log%”;

+——————+—————————-+
| Variable_name | Value |
+——————+—————————-+
| general_log | OFF |
| general_log_file | /var/run/mysqld/mysqld.log |
+——————+—————————-+

#Ativa trace log
mysql> SET GLOBAL general_log = ‘ON’;

#Desativa trace log
mysql> SET GLOBAL general_log = ‘OFF’;

 

#Verificar processos nos myql

mysqladmin -u bob -p -i 1 processlist

SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND != ‘Sleep’;
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND != ‘Sleep’ AND TIME >= 5;
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE COMMAND != ‘Sleep’ AND INFO LIKE ‘%UPDATE %’;

——————————————————–

Create a bash script called “showsqlprocesslist”:

#!/bin/bash

while [ 1 -le 1 ]
do
mysql –port=**** –protocol=tcp –password=**** –user=**** –host=**** -e “show processlist\G” | grep Info | grep -v processlist | grep -v “Info: NULL”;
done
Execute the script:

./showsqlprocesslist > showsqlprocesslist.out &
Tail the output:

tail -f showsqlprocesslist.out

——————————————————–