Account Unlock — SQL Technical Interview Questions & Answers

Account Unlock

Account Unlock

  • ALTER USER 'asha'@'localhost' ACCOUNT UNLOCK; allows login again after a lock or after password policy lockout (depending on version/settings).
  • If login still fails, the password or host ('asha'@'%') may be wrong — unlock is not a password reset.
  • Trap: UNLOCK and assuming the password is the one you remember from last year.
  • On the example next to this theory: Account Unlock: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Technical Interview Tip: ALTER USER 'asha'@'localhost' ACCOUNT UNLOCK;

Code Examples for Account Unlock

Account Unlock — sample query

-- Account Unlock
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 Unlock: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

How to Explain Account Unlock to an Interviewer

Unlock vs password reset?

Unlock allows login Password is a separate ALTER USER … IDENTIFIED BY