Hands-on Lab·MySQL
MySQL Account Locking, Revocation and Removal
Locking an account is reversible and keeps its grants; dropping it is neither. ERROR 3118 is what a locked account looks like from outside, and it is distinct from a wrong password.
Users and Privileges Guide 20 of 45 Intermediate
- OSUbuntu 26.04 LTS
- MySQL8.4.10-0ubuntu0.26.04.1
- Authcaching_sha2_password
- TimeAbout 13 min
ACCOUNT LOCK is 5.7.6+. Before that, offboarding meant dropping the account or changing its password, both of which lose information.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
This guide includes
Use this when an account has to stop working. This matters because locking is reversible and keeps every grant, while dropping is neither - and REVOKE leaves USAGE behind, which catches people out.
- locking an account without destroying anything
- seeing what a locked account looks like from the outside
- unlocking it with the mirror statement
- revoking a privilege, and watching USAGE remain regardless
- dropping the account, which takes every grant with it
Before you start
- The
supportandreportingaccounts from earlier in this track.
-
Lock an account without destroying anything
-
See what a locked account looks like from outside
-
Unlock it
-
Revoke a privilege and watch USAGE remain
-
Drop the account for good