How to Change Root Password — SQL Technical Interview Questions & Answers

How to Change Root Password

How to Change Root Password

  • Change Root 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: How to Change Root 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 How to Change Root Password

How to Change Root Password — sample query

-- How to Change Root 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;

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

How to Explain How to Change Root Password to an Interviewer

What is 'asha'@'localhost'?

A MySQL account Host is part of the identity