MySQL显示连接的数据库名
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,在默认下,MySQL在use databasename的时候,是不显示连接的库名!mysql> show databases;+--------------------+| Database |+--
千家信息网最后更新 2026年11月02日MySQL显示连接的数据库名在默认下,MySQL在use databasename的时候,是不显示连接的库名!
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hank |
| mysql |
| performance_schema |
| sakila |
| test |
| yoon |
+--------------------+
7 rows in set (0.00 sec)
mysql> use yoon;
Database changed
mysql>
可通过以下方式,实现显示连接的数据库名:
[root@hank-yoon tmp]# mysql --prompt="\u(\d) >"
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 5.6.26-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root((none)) >use yoon;
Database changed
root(yoon) >
如果想显示连接的库名和时间:
[root@hank-yoon tmp]# mysql --prompt="\u(\d) \R:\m:\s >"
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.6.26-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root((none)) 15:20:08 >use yoon
Database changed
root(yoon) 15:20:16 >
也可以添加在my.cnf配置文件中,但是需要重启DB,生产库的话,可不是随便能重启,因此在连接的时候加上即可!
[mysql]
default-character-set = utf8
prompt = \\u(\\d) \\R:\\m:\\s > \
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hank |
| mysql |
| performance_schema |
| sakila |
| test |
| yoon |
+--------------------+
7 rows in set (0.00 sec)
mysql> use yoon;
Database changed
mysql>
可通过以下方式,实现显示连接的数据库名:
[root@hank-yoon tmp]# mysql --prompt="\u(\d) >"
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 5.6.26-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root((none)) >use yoon;
Database changed
root(yoon) >
如果想显示连接的库名和时间:
[root@hank-yoon tmp]# mysql --prompt="\u(\d) \R:\m:\s >"
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.6.26-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root((none)) 15:20:08 >use yoon
Database changed
root(yoon) 15:20:16 >
也可以添加在my.cnf配置文件中,但是需要重启DB,生产库的话,可不是随便能重启,因此在连接的时候加上即可!
[mysql]
default-character-set = utf8
prompt = \\u(\\d) \\R:\\m:\\s > \
时候
数据
数据库
可不
可不是
文件
方式
时间
可通
生产
配置
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
山东特亿宝互联网科技有限公司
互联网科技垄断
互联网的科技创新
为想互联网科技
浩特互联网科技
哈尔滨秒房互联网科技有限公司
科技赋能互联网健康
深圳国际航运科技和互联网
北京华百购互联网科技有限公司
互联网大会黑科技排名
贵州叶脉互联网科技有限公司所属行业
栖莱科技互联网股份有限公司
浙江互联网科技研学营
昭通互联网科技选哪家
洛阳昕诺飞互联网科技有限公司
互联网数据科技专业
互联网科技如何创业
科技互联网海报
北京天晋互联网科技有限公司
互联网对科技影响
为想互联网科技怎么样
互联网品科技
互联网科技战争
互联网科技上市公司
新浪科技互联网
互联网科技公司介绍
互联网养老 桔豆科技
居家互联网科技有限公司
济南和联互联网科技有限公司
山东有哪些互联网科技公司