这里会显示出您选择的修订版和当前版本之间的差别。
— |
vps:mysql:commands [2014/05/25 01:27] (当前版本) |
||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== 利用命令行查看Mysql数据库 ====== | ||
+ | |||
+ | ===== 进入mysql命令行模式 ===== | ||
+ | <code> | ||
+ | mysql -u username -p <password> | ||
+ | </code> | ||
+ | ===== 查看数据库列表 ===== | ||
+ | |||
+ | 1. show databases | ||
+ | |||
+ | 查看所有的数据库,等同于 | ||
+ | |||
+ | select schema_name from information_schema.schemata\G | ||
+ | |||
+ | \G 替换;,以纵向报表的形式输出结果,有利于阅读。 | ||
+ | |||
+ | 2. status 查看mysql数据库的运行状态 | ||
+ | |||
+ | 3. use 命令选择数据库 例如 use information_schema,当使用此命令后 | ||
+ | |||
+ | |||
+ | select schema_name from information_schema.schemata\G | ||
+ | |||
+ | 可以为 | ||
+ | |||
+ | select schema_name from schemata\G | ||
+ | |||
+ | |||
+ | 4. 查看数据库中的表 | ||
+ | |||
+ | show tables | ||
+ | |||
+ | 同样也可以在information_schema中查看,show命令是方便使用的简短模式。 | ||
+ | |||
+ | select table_name from tables where table_schema='jblog'; | ||
+ | |||
+ | 5. 查看表结构 | ||
+ | |||
+ | desc table_name; | ||
+ | |||
+ | 6.查看表状态 show table status from db like 条件 | ||
+ | |||
+ | 可以查看engine数据库引擎,version,row、index等信息 | ||
+ | |||
+ | 7.小技巧,当多行命令输入,发现错误后,用\c结束。 | ||