MariaDB Show Grants for Current_user Docs
You can check your active database privileges by running the built-in show grants command. The official mariadb show grants for current_user docs explain how the server checks your login identity. Most engineering teams run this check when a query fails due to missing table rights. Teams often fix these errors by granting broad roles to shared accounts. Overly broad permissions let anyone on that account drop tables or read private user rows. How the mariadb show grants for current_user docs e
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.
You can check your active database privileges by running the built-in show grants command. The official mariadb show grants for current_user docs explain how the server checks your login identity. Most engineering teams run this check when a query fails due to missing table rights. Teams often fix these errors by granting broad roles to shared accounts. Overly broad permissions let anyone on that account drop tables or read private user rows.
How the mariadb show grants for current_user docs explain privileges
MariaDB tracks two separate user values during every active database session. One value holds the exact name and host you used when logging in. The other value holds the account entry from the server grant tables that matched your login. When you check grants for the current user, MariaDB inspects that matched grant table entry. The database returns a list of privilege statements that build your current access profile.
These privilege rules live inside internal system tables on the database server. The server loads these rules into memory when it starts up or reloads grants. Global rules apply to every database on the server. Database level rules apply to all tables inside one specific schema. Table and column rules narrow those rights down to single objects or fields.
MariaDB also supports role assignments that group multiple privileges together under one name. A user can hold several roles at once, some active and some inactive. The show grants output reveals both direct account privileges and any active default roles. Admins read this output to confirm why a specific session can or cannot run a query.
Why static database grants leave an operational gap
Checking account privileges helps teams fix broken app connections and verify basic role setup. It shows the static ceiling of what a logged-in account is allowed to do. Still, static grant tables only decide who logs in and which objects they can touch. They cannot inspect the intent or risk of individual queries running in flight.
Suppose a developer needs to check production orders during an outage. You give their account read access to the customer table so they can debug. That static grant allows a simple row lookup, which is safe. It also allows a full table dump of every email and phone number, which is risky. Native grants treat both queries the exact same way.
Time-Bound Access Grants + User Provisioning (SCIM): architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Teams also struggle with shared database accounts across multiple people or tools. When five engineers share one login, the server logs show the same current user for all of them. You lose clear audit trails showing which person ran a specific update statement. Also, static read grants return raw card numbers and national IDs in full text. Database admins must either revoke table access or accept that queries return raw sensitive fields.
Auditing and scoping database sessions beyond static roles
Good security requires pairing clean grant tables with runtime checks on every query. Teams should start by removing global privileges from human accounts and daily support roles. Give each service its own account scoped to one database schema. Review your grant outputs on a regular schedule to clear out old permissions.
For human access, move away from permanent static roles that sit open all day. Engineers need a way to run safe read queries without pulling raw private data. When a query runs, field masking should rewrite emails and card numbers in the results. Risky write statements should pause for peer approval before they reach the database engine. This approach keeps your grant tables clean while controlling what each session does in real time.
Add wire guardrails and masking beside MySQL
Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.
With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. Data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.
Frequently asked questions
What is the difference between user and current_user in MariaDB?
The user function returns the exact name and client host you sent during login. The current_user function returns the account entry from the server grant tables that matched your login. These two values differ when you match a wildcard host rule or an anonymous account.
Do I need special admin rights to check my own grants?
No, any logged-in session can view its own active privileges without extra admin rights. You only need higher system table permissions when you want to inspect grants for other accounts. This lets developers check their own session rights during routine debugging.
Why are some assigned roles missing from my grant output?
MariaDB allows accounts to hold roles that are not active by default at login. If a role is not set as a default role, you must activate it during your session. Checking grants for the current user only displays the privileges and roles active right now.
Related guides
In this post