mysql 查看数据库、表的基本命令

1:show databases;

查看所有的数据库,等同于select schema_name from information_schema.schemata\G。\G 替换;,以纵向报表的形式输出结果,有利于阅读。

  1. status 查看mysql数据库的运行状态

  2. use 命令选择数据库 例如 use information_schema,当使用此命令后

select schema_name from information_schema.schemata\G,可以为

select schema_name from schemata\G

  1. 查看数据库中的表

show tables

同样也可以在information_schema中查看,show命令是方便使用的简短模式。

select table_name from tables where table_schema='jblog';

  1. 查看表结构

desc table_name;

6.查看表状态 show table status from db like 条件

可以查看engine数据库引擎,version,row、index等信息

7.小技巧,当多行命令输入,发现错误后,用\c结束。


另,查询数据库运行状态的基本命令:

#查询数据库连接

show ``full processlist;

show status ``like '%Max_used_connections%'``;

show status ``like '%Threads_connected%'``;#当前连接数

show status ``like '%table_lock%'``;#表锁定

show status ``like 'innodb_row_lock%'``;#行锁定

show status ``like '%qcache%'``; #查询缓存情况

show variables ``like "%query_cache%"``;

SHOW STATUS ``LIKE 'Qcache%'``;

show variables ``like "%binlog%"``;

show status ``like 'Aborted_clients'``;#由于客户没有正确关闭连接已经死掉,已经放弃的连接数量

show variables ``like '%max_connections%'``;//查看最大连接数量

show variables ``like '%timeout%'``;#查看超时时间

show variables ``like 'log_%'``; #查看日志是否启动

相关推荐
弥生赞歌12 分钟前
Mysql作业四
数据库·mysql
Lethehong4 小时前
百万迁移费成历史?金仓数据库“零代码”替换Oracle,我们扒了扒它的技术底牌
后端·mysql·架构
Dev7z5 小时前
MySQL 错误 1046 (3D000) 是因为在执行 SQL 语句时 没有选择当前数据库
数据库·sql·mysql
wangchen_05 小时前
MySQL表的查询
数据库·mysql
unicrom_深圳市由你创科技6 小时前
MySQL 全文索引进阶:中文分词配置 + 模糊查询性能优化
mysql·性能优化·中文分词
沐浴露z6 小时前
详细解析 MySQL 性能优化之【索引下推】
数据库·mysql·性能优化
程序员卷卷狗7 小时前
联合索引的最左前缀原则与失效场景
java·开发语言·数据库·mysql
敖云岚8 小时前
【疑难解答】MySQL 报错 Public Key Retrieval is not allowed
数据库·mysql
ヾChen9 小时前
MySQL——增删改查操作
数据库·sql·物联网·学习·mysql
0和1的舞者9 小时前
《MySQL数据库进阶(九):数据库备份与恢复(二)》
数据库·mysql·oracle·程序员·策略模式·备份与恢复