The mysql program is the official interactive client. Statements end with ;; backslash commands start with \.
Connect
# Shell:
mysql -u root -p -h 127.0.0.1 practice
-- Inside mysql:
SELECT DATABASE();
SHOW VARIABLES LIKE 'version%';Practice: Run on database practice in mysql client.
Help and history
help;
help SELECT;
\s
\q -- quit
Running scripts
SOURCE /path/to/seed.sql;
Important interview questions and answers
- Q: mysql vs mysqld?
A: mysql is client; mysqld is server daemon. - Q: SOURCE command?
A: Executes SQL file in current session.
Self-check
- How do you quit mysql client?
- What shows current database name?
Pitfall: Forgetting semicolon—mysql waits for statement end.
Interview prep
- mysql vs mysqld?
Client program vs server daemon.
- SOURCE?
Runs SQL from file in current session.