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

相关推荐
ClouGence8 小时前
最基础的异构数据库 DDL 同步,我们踩过哪些坑?
数据库·mysql·postgresql
小呆爱发呆9 小时前
第三章 MySQL 库表操作
数据库·mysql·adb
普通人611 小时前
MySQL_FIND_IN_SET函数详解
android·数据库·mysql
真上帝的左手11 小时前
4. 关系型数据库-MySQL-Canal 进阶
数据库·mysql·canal
codeejun11 小时前
每日一Go·MySQL-14、慢 SQL 产生原因全解
sql·mysql·golang
星恒随风1 天前
MySQL 从零入门(四):表的增删改查与基础查询详解
linux·服务器·数据库·笔记·mysql
Pniubi1 天前
MySQL靠什么实现事务的?事务隔离级别有哪些?
java·数据库·mysql
aiks_yuan1 天前
MySQL 死锁怎么排查:看懂 INNODB STATUS 死锁日志,先查后插为什么必死锁(MySQL 8.2 实测)
mysql
进击的荆棘1 天前
MySQL——库的操作
数据库·mysql
计算机毕设定制辅导-无忧学长1 天前
《基于Spring Boot的迷游哈游戏综合服务平台的开发》
java·vue.js·spring boot·mysql·迷游哈游戏综合服务平台