I need to view only my own running queries in MySQL 5, but I’m having trouble filtering the results properly.
My account has the PROCESS privilege, so when I run SHOW PROCESSLIST, it returns all active processes from every user on the server. I checked the MySQL docs and found out that SHOW PROCESSLIST doesn’t support WHERE clauses, and I couldn’t figure out how to use it as a subquery either.
I know I could write some PHP code to loop through all the results and filter out processes that don’t belong to my user account, but that approach feels wasteful and slow. I also can’t modify the user permissions since that’s not an option in my situation.
Does anyone know of alternative methods to accomplish this? Any help would be appreciated.
yo, just check out information_schema.processlist instead of that SHOW PROCESSLIST stuff. try this: SELECT * FROM information_schema.processlist WHERE USER = USER(); it’ll filter by your username n works great in MySQL 5. same info, but with WHERE clause!
PERFORMANCE_SCHEMA works great if it’s enabled on your MySQL instance. Just query the performance_schema.processlist table with WHERE filtering like the information_schema method. But heads up - it’s not available on all MySQL 5 setups depending on your config. You can also use SHOW FULL PROCESSLIST piped through system tools if you’ve got shell access. Connect via mysql client and filter the output, though you’ll need extra privileges. I’ve found information_schema.processlist to be the most reliable across different MySQL 5 environments. Make sure your connection timeout settings are high enough if you’re monitoring long-running processes - your own connection will show up in the results too.
Manual queries every time you check processes? Gets old fast. Been there with multiple database environments.
Yeah, information_schema.processlist works, but who wants to type the same query constantly? Automate it.
I built a simple workflow that monitors MySQL processes automatically. Connects to the database, pulls from information_schema.processlist with user filtering, and alerts me when queries run too long. No more manual checking.
Expand it to log query patterns, track performance, or auto-kill runaway processes. Beats remembering SQL syntax when you’re debugging.
10 minutes to set up, saves hours of manual work. Check it out: https://latenode.com
hey, if u use MySQL Workbench or other GUI tools, they usually have process filtering built in. saves time on queries! but for scripts or checks, stick with information_schema.processlist - it’s super reliable.
The information_schema approach is your best bet. I hit this same issue debugging slow queries on a shared server. What worked for me: SELECT * FROM information_schema.processlist WHERE USER = SUBSTRING_INDEX(USER(), '@', 1); instead of just USER(). USER() sometimes returns the full user@host format, but processlist might only store the username part. You can add AND COMMAND != 'Sleep' to filter out idle connections if you only want active queries. This method’s worked solid across different MySQL 5.x versions for me.