How to Check MySQL Query Logs
To learn how to check mysql query logs, turn on general and slow logs in your database. You can then read these records from host files or system tables. Database teams use these logs to track who ran which statements and when. Today, both human developers and AI agents run queries against production databases. Checking query logs helps you spot bad queries, find slow steps, and audit user activity. How to check mysql query logs in daily work MySQL gives you two main log types to track SQL s
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
To learn how to check mysql query logs, turn on general and slow logs in your database. You can then read these records from host files or system tables.
Database teams use these logs to track who ran which statements and when. Today, both human developers and AI agents run queries against production databases. Checking query logs helps you spot bad queries, find slow steps, and audit user activity.
How to check mysql query logs in daily work
MySQL gives you two main log types to track SQL statements. The general query log records every client connection and every statement the server gets. The slow query log only records statements that take too long to finish. By default, most database setups keep the general log off to save disk space.
You must turn on these logs in your database settings before you can read them. You can tell the server to write logs to a file on the disk. You can also tell the server to write logs into internal system tables. Each method changes how your team reads the data later.
When the server writes to a file, engineers need host access to read it. They log in to the host server and read the text files on disk. In managed cloud databases, teams read or download these files from the cloud console. They can also send the log stream to a central log tool.
When the server writes to system tables, engineers check logs using standard SQL queries. They log in to the database client and read the log tables directly. AI agents that help debug performance also read these system tables to inspect past queries. This method lets you filter by time, user account, or statement text.
Security and performance limits of native MySQL logs
Turning on the general query log creates heavy disk write load on busy servers. Every single query writes a new line to the disk or table right away. This extra work can slow down your main app during peak traffic hours. Because of this cost, teams rarely leave the general log on all the time.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Native query logs also rely on static database accounts and shared roles. Many apps, engineers, and AI agents log in using the same shared database user. When you check the log, you only see that shared user name. You cannot tell which specific engineer or AI agent ran a risky command.
Logs also create a new place where private customer data can leak. If a query includes an email or phone number, the log stores that text. Anyone with permission to read the logs can now see those raw values. Static roles cannot rewrite matched fields like card numbers or national IDs in results.
Finally, native logs only tell you what happened after the query already ran. They do not block a bad delete statement or require peer review before execution. To get real user identity and active controls, teams put a proxy in front of MySQL. This layer logs every query by person while masking matched fields in results.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
Where does MySQL store query logs by default?
MySQL stores query log files in the main data folder on the database host. You can also set up the server to store logs inside internal system tables.
Does turning on the general query log slow down MySQL?
Yes, logging every query adds disk writes and can slow down busy production servers. Most teams only turn it on for short debug windows or use external proxies.
Can MySQL query logs show which developer ran a query?
Native logs only show the database account name used to open the session. If your team shares one database user, the log cannot show the exact person.
Related guides
In this post