IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

三十六、MySQL 获取服务器元数据

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

文章永久连接:https://tech.souyunku.com/?p=4929

如果想要获取服务器的元数据,可以使用下表的语句

命令 说明
SELECT VERSION() 返回服务器版本信息
SELECT DATABASE() 返回当前数据库名 (或者返回空)
SELECT USER() 返回当前用户名
SHOW STATUS 返回服务器状态
SHOW VARIABLES 返回服务器配置变量

SELECT VERSION() 获取服务器版本信息

MariaDB [souyunku]> SELECT VERSION();
+-----------------+
| VERSION()       |
+-----------------+
| 10.2.13-MariaDB |
+-----------------+
1 row in set (0.01 sec)

SELECT DATABASE() 获取当前数据库名

MariaDB [souyunku]> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| souyunku       |
+------------+
1 row in set (0.00 sec)

如果当前没有选择任何数据库,则返回 NULL

MariaDB [(none)]> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| NULL       |
+------------+
1 row in set (0.00 sec)

SELECT USER() 获取当前用户名

MariaDB [(none)]> SELECT USER();
+----------------+
| USER()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

SHOW STATUS 获取服务器状态

MariaDB [(none)]> SHOW STATUS;
+----------------------+----------------------------------+
| Variable_name        | Value                            |
+----------------------+----------------------------------+
| Aborted_clients      | 14                               |
| Aborted_connects     | 0                                |
| Access_denied_errors | 0                                |
| Acl_column_grants    | 0                                |
| Acl_database_grants  | 2                                |
| Acl_function_grants  | 0                                |
| Acl_procedure_grants | 
| Binlog_commits       | 0                                |
....
....
483 rows in set (0.02 sec)

非常多数据,看不完,我们一般会使用 LIKE 语句查询某些具体的值,比如使用下面的语句查询缓存命中率相关的信息

SHOW STATUS LIKE '%Qcache%';

运行结果如下

MariaDB [(none)]> SHOW STATUS LIKE '%Qcache%';
+-------------------------+---------+
| Variable_name           | Value   |
+-------------------------+---------+
| Qcache_free_blocks      | 1       |
| Qcache_free_memory      | 1031312 |
| Qcache_hits             | 0       |
| Qcache_inserts          | 0       |
| Qcache_lowmem_prunes    | 0       |
| Qcache_not_cached       | 0       |
| Qcache_queries_in_cache | 0       |
| Qcache_total_blocks     | 1       |
+-------------------------+---------+
8 rows in set (0.00 sec)

SHOW VARIABLES 获取服务器配置变量

MariaDB [(none)]> SHOW VARIABLES\G;
*********************** 626. row ***********************
Variable_name: wsrep_slave_threads
        Value: 1
*********************** 627. row ***********************
Variable_name: wsrep_sst_auth
        Value: 
*********************** 628. row ***********************
Variable_name: wsrep_sst_donor
        Value: 
*********************** 629. row ***********************
Variable_name: wsrep_sst_donor_rejects_queries
        Value: OFF
*********************** 630. row ***********************
Variable_name: wsrep_sst_method
        Value: rsync
*********************** 631. row ***********************
Variable_name: wsrep_sst_receive_address
        Value: AUTO
*********************** 632. row ***********************
Variable_name: wsrep_start_position
        Value: 00000000-0000-0000-0000-000000000000:-1
*************************** 633. row ********************
Variable_name: wsrep_sync_wait
        Value: 0
633 rows in set (0.01 sec)
...
...
633 rows in set (0.02 sec)

非常多数据,看不完,我们一般会使用 LIKE 语句查询某些具体的值,比如使用下面的语句查询编码相关信息

SHOW VARIABLES LIKE '%character%';

运行结果如下

MariaDB [(none)]> SHOW VARIABLES LIKE '%character%';
+-----------------------------------------------------------+
| Variable_name            | Value                                                   |
+--------------------------+--------------------------------+
| character_set_client     | utf8                                                    |
| character_set_connection | utf8                                                    |
| character_set_database   | utf8                                                    |
| character_set_filesystem | binary                                                  |
| character_set_results    | utf8                                                    |
| character_set_server     | utf8                                                    |
| character_set_system     | utf8                                                    |
| character_sets_dir       | .../share/mysql/charsets/      |
+--------------------------+--------------------------------+
8 rows in set (0.00 sec)

干货推荐

本站推荐:精选优质专栏

附录:MySQL 教程:系列文章


Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(64) 打赏



未经允许不得转载:搜云库技术团队 » 三十六、MySQL 获取服务器元数据

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367