PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

Account Lock

← All stacks

Theory

28/439

Account Lock

ALTER USER 'asha'@'localhost' ACCOUNT LOCK; stops that MySQL user from logging in. Unlock with ACCOUNT UNLOCK. This is a user account, not a table row.

Use it when a intern leaves or a password leak happens — lock first, rotate password, unlock if needed.

Trap — confusing ACCOUNT LOCK with LOCK TABLES.

On the example next to this theory: Account Lock: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Exam tip

ALTER USER 'asha'@'localhost' ACCOUNT LOCK;

Account Lock — sample query

-- Account Lock
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

Account Lock: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Short notes

  • DefACCOUNT LOCK disables a MySQL login.
  • RuleALTER USER 'u'@'host' ACCOUNT LOCK;
  • TrapMixing this with table LOCK TABLES.

Questions

1

What does ACCOUNT LOCK do?

28 / 439

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.