MySQL查看数据库、用户、运行状态

一、查看Mysql版本

//方式一
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.22    |
+-----------+
1 row in set (0.00 sec)



//方式二
mysql> select @@version ;
+-----------+
| @@version |
+-----------+
| 5.7.22    |
+-----------+
1 row in set (0.00 sec)


//方式三

mysql> status
--------------
mysql  Ver 14.14 Distrib 5.7.22, for Win64 (x86_64)

Connection id:          21
Current database:
Current user:           root@localhost
SSL:                    Not in use
Using delimiter:        ;
Server version:         5.7.22 MySQL Community Server (GPL)
Protocol version:       10
Connection:             localhost via TCP/IP
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
TCP port:               3306
Uptime:                 179 days 16 hours 46 sec

Threads: 16  Questions: 92  Slow queries: 0  Opens: 29  Flush tables: 1
  Open tables: 20  Queries per second avg: 1.826
--------------

mysql>

二、存储引擎

mysql已提供的存储引擎:
mysql> show engines;

//mysql当前默认的存储引擎:
mysql> show variables like '%storage_engine%';
+----------------------------------+--------+
| Variable_name                    | Value  |
+----------------------------------+--------+
| default_storage_engine           | InnoDB |
| default_tmp_storage_engine       | InnoDB |
| disabled_storage_engines         |        |
| internal_tmp_disk_storage_engine | InnoDB |
+----------------------------------+--------+
4 rows in set, 1 warning (0.00 sec)

三、查看用户

1、查看Mysql的当前用户
mysql> SELECT USER ();
+-----------------------+
| USER ()               |
+-----------------------+
| root@localhost |
+-----------------------+
1 row in set (0.00 sec)

mysql>

2、查看所有用户

mysql> SELECT user,host FROM mysql.user;
+--------------------+---------------+
| user               | host          |
+--------------------+---------------+
| test               | %             |
| test               | localhost     |
| aser               | 192.168.1.64  |
| aser               | localhost     |
| mysql.session      | localhost     |
| mysql.sys          | localhost     |
| root               | localhost     |
+--------------------+---------------+
7 rows in set (0.00 sec)

四、查看数据库及表信息

//1、显示数据库列表。 
show databases; 
//2、显示库中的数据表: 
use mysql;
show tables; 
//3、显示数据表的结构: 
describe 表名; 


# 查看当前连接的数据库
mysql> select database();
+------------+
| database() |
+------------+
| testdb       |
+------------+
1 row in set (0.00 sec)

mysql>

五、数据库运行状态的基本命令

show full  processlist; # 查询数据库连接
show variables like '%max_connections%';# 查看最大连接数量
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 '%timeout%';# 查看超时时间
show variables like 'log_%'; # 查看日志是否启动

你可能感兴趣的:(#,Mysql,mysql)