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_%'``; #查看日志是否启动

相关推荐
陈卿诺语37 分钟前
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
sql·mysql·adb
南城以南溫暖如初14740 分钟前
社区健身小程序开发流程详解:技术选型与实施经验分享
java·经验分享·spring boot·mysql·vue·apache
️学习的小王2 小时前
MySQL常用函数知识点总结
数据库·mysql·oracle
万亿少女的梦1683 小时前
基于Spring Boot、Java与MySQL的同城宠物服务系统设计与实现
java·spring boot·mysql·系统设计·协同过滤
万亿少女的梦1683 小时前
基于Spring Boot、Vue与MySQL的私人健身教练预约管理系统设计
java·spring boot·mysql·vue·预约管理
灯澜忆梦13 小时前
【MySQL12】进阶篇 | SQL优化
数据库·sql·mysql·性能优化
东方护航数据恢复(深圳)20 小时前
MySQL_Oracle数据库崩溃修复全攻略_东方护航数据恢复深圳店
数据库·mysql·oracle
ruleslol1 天前
index merge避免回表
mysql
码农颜1 天前
5.5.2 MVCC 多版本实现
java·数据库·mysql
北风toto1 天前
MySQL 批量随机化主键 ID,如何同步更新关联子表?
数据库·mysql