Mysql 常用命令
1.mysql 导出数据库脚本:
mysqldump -h10.10.10.10 -uusername -ppassword -d dataBase > /tmp/dataBase.sql
2.mysql 导入数据库脚本:
mysql -h10.10.10.10 -uusername -ppassword -DdataBase</tmp/xxx.sql
3.mysql 查询出表结构和字段信息:
SELECT a1.表注释, a2.表名, a2.列名, a2.数据类型, a2.字段类型, a2.长度, a2.是否为空, a2.默认值, a2.备注 FROM ( SELECT TABLE_NAME AS 表名, TABLE_COMMENT AS 表注释 FROM INFORMATION_SCHEMA. TABLES WHERE TABLE_SCHEMA = 'dataBaseName' AND TABLE_NAME IN ('tableName1', 'tableName2') ) a1 INNER JOIN ( SELECT table_name 表名, COLUMN_NAME 列名, COLUMN_TYPE 数据类型, DATA_TYPE 字段类型, CHARACTER_MAXIMUM_LENGTH 长度, IS_NULLABLE 是否为空, COLUMN_DEFAULT 默认值, COLUMN_COMMENT 备注 FROM INFORMATION_SCHEMA. COLUMNS WHERE table_schema = 'dataBaseName' AND table_name IN ('tableName1', 'tableName2') ) a2 ON a1.`表名` = a2.`表名`