I AM NOT RUNNING THE COMMANDS FROM PHP!
I have MySQL log_error value set to /var/log/mysql/error.log
However when I connect to a database and run an SQL command,
This is not so trivial. The best way to do this, is to log bad queries in your application. There is no built-in way.