Change User Password — SQL Technical Interview Questions & Answers

Change User Password

Change User Password

  • Change User Password is about MySQL accounts, not table rows. Users are 'name'@'host'. CREATE USER, GRANT, ALTER USER … IDENTIFIED BY, DROP USER.
  • SHOW GRANTS FOR CURRENT_USER; to see yourself. Don’t use root from the app. Lock/unlock is ACCOUNT LOCK.
  • Trap: user@localhost vs user@% as two different accounts.
  • On the example next to this theory: Change User Password: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Technical Interview Tip: 'user'@'host', GRANT, not root from the app.

Code Examples for Change User Password

Change User Password — sample query

-- Change User Password
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;

Change User Password: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

How to Explain Change User Password to an Interviewer

What is 'asha'@'localhost'?

A MySQL account Host is part of the identity