How to enable general query logging?

To enable general query logging in MySQL, you can use the following command:

sudo mysql -u root -e "SET GLOBAL general_log = 'ON';"

Here's a breakdown of the command:

  • sudo: Runs the command with superuser privileges.
  • mysql: The MySQL command-line client.
  • -u root: Connects as the root user.
  • -e: Executes the command directly.
  • "SET GLOBAL general_log = 'ON';": This SQL command enables the general query log.

After running this command, MySQL will start logging all queries. If you want to make this change permanent, you can add the following line to your MySQL configuration file (usually my.cnf or my.ini):

[mysqld]
general_log = 1

Then restart the MySQL service for the changes to take effect. If you have any more questions, feel free to ask!

0 Comments

no data
Be the first to share your comment!