Connect/Disconnect
1 | mysql -h <host> -u <user> -p<passwd> |
Query
1 | SELECT * FROM table |
Conditionals
1 | field1 = value1 |
table Index
1 | CREATE [UNIQUE|FULLTEXT] INDEX index_name ON table (column,...) |
Data Manipulation
1 | INSERT INTO table1 (field1, field2, ...) VALUES (value1, value2, ...) |
Browsing
1 | SHOW DATABASES |
Create / delete / select / alter database
1 | CREATE DATABASE [IF NOT EXISTS] mabase [CHARACTER SET charset] [COLLATE collation] |
Create table
1 | CREATE TABLE table (field1 type1, field2 type2, ...) |
delete table
1 | DROP TABLE table |
modify table
1 | ALTER TABLE table MODIFY field1 type1 |
create/modify/drop view
1 | CREATE VIEW view AS SELECT ... FROM table WHERE ... |
Privileges
1 | CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'; |
Main data types
1 | TINYINT (1o: -127+128) |
Forgot root password?
1 | $ /etc/init.d/mysql stop |
Repair tables after unclean shutdown
1 | mysqlcheck --all-databases |
Loading data
1 | mysql> SOURCE input_file |