VoidZA VoidZA - 1 month ago 8
Linux Question

mySQL in server Terminal, need to see output

I am a little bit stuck having to execute a mySQL query in the terminal of one of my servers.

Here is how far I got:

mysql -u GJHGKfdkGm3NPdj -p m9qHkDMVj9qHkDH1 websitedb-wp-z3Fh5kp7 -e "SHOW PROCESSLIST;"


So basically something is eating my server and I wanted to see what was going on in my SQL when I refresh pages. I'm really on the new side of terminal commands, so I'm not sure if its structured right, but I will need to have the results echoed out as well.

Answer

You can enable logging for your mysql server with the following command:

mysql -u GJHGKfdkGm3NPdj -p m9qHkDMVj9qHkDH1 -e "SET GLOBAL general_log = 1;"

Then you should use tail command for the log:

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

You can check the path to your log file with the following command:

mysql -u GJHGKfdkGm3NPdj -p m9qHkDMVj9qHkDH1 -e "show variables LIKE 'general_log_file';"