Essential MySQL Command-Line Client Commands

Before reaching for a GUI, the mysql command-line client is worth knowing well — faster for quick checks, and it’s the one tool guaranteed to be available on any server you SSH into.

mysql -u root -p

-- Inside the client:
SHOW DATABASES;
USE mydb;
SHOW TABLES;
DESCRIBE products;
SHOW CREATE TABLE products\G      -- \G formats output vertically, readable for wide rows
SHOW PROCESSLIST;                  -- see currently running queries
SHOW VARIABLES LIKE 'max_connections';
STATUS;                            -- connection and server info

-- Run a query directly from the shell without an interactive session
mysql -u root -p -e "SELECT COUNT(*) FROM orders" mydb

\G instead of a trailing semicolon is a small but genuinely useful habit — it prints each column on its own line instead of a wide table, which is far more readable for tables with many or long columns.