How to show the last queries executed on MySQL?
Spread the love

What is MySQL?

MySQL is free and open-source software under the terms of the GNU General Public License, and is also available under a variety of proprietary licenses.

MySQL was owned and sponsored by the Swedish company MySQL AB, which was bought by Sun Microsystems In 2010, when Oracle acquired Sun, Widenius forked the open-source MySQL project to create MariaDB.

How to show the last queries in MySQL?

You can enable a general query log for diagnostic purposes. Generally you don’t log all SELECT queries on a production server though it, it’s a performance killer.
Edit your MySQL config, e.g. /etc/mysql/my.cnf – look for, or add, a line like this:

[mysqld] log = /var/log/mysql/mysql.log
Code language: JavaScript (javascript)

Restart mysql to pick up that change, now you can:

tail -f /var/log/mysql/mysql.log
Code language: JavaScript (javascript)


Hey presto, you can watch the queries as they come in.

We hope you enjoyed this article. if that is so please rate this page with the stars bellow and subscribe to our YouTube channel.

Facebook Comments Box