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

相关推荐
r_oo_ki_e_28 分钟前
快速复习mysql
数据库·mysql
羊小蜜.1 小时前
Mysql 03: 连接查询全解——内连接、外连接与复合条件查询
数据库·mysql·算法·连接查询
Java水解1 小时前
【MYSQL】MYSQL学习的一大重点:MYSQL数据类型
后端·mysql
polaris06301 小时前
完美解决phpstudy安装后mysql无法启动
数据库·mysql
笑梦无境2 小时前
mysql基础篇四(多年前整理)
数据库·mysql
yy55272 小时前
Mysql 主从复制与读写分离
android·数据库·mysql
zhenxin01223 小时前
万字详解 MySQL MGR 高可用集群搭建
android·mysql·adb
xxjj998a3 小时前
从MySQL迁移到PostgreSQL的完整指南
数据库·mysql·postgresql
Three~stone3 小时前
MySQL Workbench 8.0.45 安装教程[附安装包]
数据库·mysql
炸炸鱼.3 小时前
MySQL 高可用实战(主主复制 + Keepalived+HAProxy)
数据库·mysql·adb