Connection and sessionMySQL
mysql
Open a MySQL client session with authentication options.
mysql -u <user> -p
Connection management, schema evolution, SQL data operations, and backups.
Open a MySQL client session with authentication options.
mysql -u <user> -p
Perform administrative operations like ping or shutdown.
mysqladmin -u <user> -p ping
Provision a new database with optional character set.
CREATE DATABASE <db_name> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
DESCRIBE
List tables and inspect column metadata.
SHOW TABLES;
Modify table structure by adding columns or indexes.
ALTER TABLE <table> ADD COLUMN <column> VARCHAR(255) NOT NULL;
Query rows with filters, ordering, and limits.
SELECT * FROM <table> WHERE <column> = '<value>' ORDER BY created_at DESC LIMIT 20;
UPDATE
DELETE
Mutate data within transactional contexts.
INSERT INTO <table> (<column1>,<column2>) VALUES ('<value1>','<value2>');
Bulk import data from flat files.
LOAD DATA LOCAL INFILE '<path>.csv' INTO TABLE <table> FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' IGNORE 1 LINES;
Export databases or selected tables to SQL dumps.
mysqldump -u <user> -p <database> > backup.sql
Load data files generated by mysqldump or other sources.
mysqlimport --local -u <user> -p <database> <table>.txt
Inspect currently running queries and connections.
SHOW FULL PROCESSLIST;