Common used mysql command
Create database and user
Create database:
shell> mysqladmin -u root -p create xxx
Create user:
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX,CREATE TEMPORARY TABLES,LOCK TABLES ON xxx.* TO 'user'@'localhost' IDENTIFIED BY 'password';
Check and modify the field definition
Get the information about the fields in a table:
mysql> DESC tbl_name;
Change the field definition of an existing table:
mysql> ALTER TABLE tbl_name CHANGE old_col_name new_col_name col_type
Add new field:
mysql> ALTER TABLE tbl_name ADD col_name col_type AFTER old_col_name