`
sjk2013
  • 浏览: 2183549 次
文章分类
社区版块
存档分类
最新评论

个性化设置 MySQL prompt 提示符

 
阅读更多
面谈 4 种方法


㈠ 在 Bash 层修改 MYSQL_PS1 变量


[root@localhost ~]# export MYSQL_PS1="(\u@\h) [\d]> "
[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 73
Server version: 5.5.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2012, 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@localhost) [(none)]> use test;
Database changed
(root@localhost) [test]> 


㈡ MySQL 命令行参数


[root@localhost ~]# mysql -u root -p --prompt="(\u@\h) [\d]> "
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 74
Server version: 5.5.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2012, 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@localhost) [(none)]> 


㈢ 配置文件 /etc/my.cnf


[mysql]
prompt=(\\u@\\h) [\\d]>\\_
 
又或者:
[mysql]
prompt="\\r:\\m:\\s> "

要多加一个反斜线\.


㈣ 在 MySQL 中使用 prompt 命令


mysql> prompt \r:\m:\s\P>\_
PROMPT set to '\r:\m:\s\P>\_'
08:20:42pm> prompt
Returning to default PROMPT of mysql> 
mysql> 


附录:


Option	Description

\c	A counter that increments for each statement you issue
\D	The full current date
\d	The default database
\h	The server host
\l	The current delimiter (new in 5.0.25)
\m	Minutes of the current time
\n	A newline character
\O	The current month in three-letter format (Jan, Feb, …)
\o	The current month in numeric format
\P	am/pm
\p	The current TCP/IP port or socket file
\R	The current time, in 24-hour military time (0–23)
\r	The current time, standard 12-hour time (1–12)
\S	Semicolon
\s	Seconds of the current time
\t	A tab character
\U	
Your full user_name@host_name account name
 
\u	Your user name
\v	The server version
\w	The current day of the week in three-letter format (Mon, Tue, …)
\Y	The current year, four digits
\y	The current year, two digits
\_	A space
\ 	A space (a space follows the backslash)
\'	Single quote
\"	Double quote
\\	A literal “\” backslash character
\x	
x, for any “x” not listed above


分享到:
评论

相关推荐

    mysql 控制台程序的提示符 prompt 字符串设置

    The prompt command ... 该提示符可用根据需要进行修改设置: 有以下几种设置方式: 设置shell 的环境变量 : MYSQL_PS1 shell> export MYSQL_PS1=”(\u@\h) [\d]> ” 使用程序启动命令选项 : –prompt shell> mysql –p

    mysql prompt的用法详解

    prompt命令可以在mysql提示符中显示当前用户、数据库、时间等信息 代码如下:mysql -uroot -p –prompt=”\\u@\\h:\\d \\r:\\m:\\s>”设置成功后: 代码如下:Welcome to the MySQL monitor. Commands end with ; or ...

    SQLPrompt查询分析界面提示功能

    SQLPrompt查询分析界面提示功能,在数据库自动提示帮助应用,智能提示应用

    巧用mysql提示符prompt清晰管理数据库的方法

    随着管理mysql服务器越来越多,同样的mysql>的提示符有可能会让你输入错误的命令到错误的数据库,这时候需要巧用mysql的提示符,这是我的提示符root@localhost(mysql) 08:55:21> 用prompt命令实现(适用于windows和...

    SQLPrompt格式化工具

    SQLPrompt 好用的格式化工具

    SQLPrompt for SQLServer2016 智能提示插件 SQL2016 提示

    SQLPrompt for SQLServer2016 智能提示插件 SQL2016 提示 SQLPrompt最新版本 绿色版 SQL Prompt 是一款拥有SQL智能提示功能的SQL Server和VS插件。SQL Prompt能根据数据库的对象名称,语法和用户编写的代码片段自动...

    Windows操作系统中的CMD(命令提示符).md

    "CMD" 通常指的是 Windows 操作系统中的命令提示符(Command Prompt)。它是 Windows 系统自带的命令行工具,允许用户通过输入命令来执行各种系统任务和管理操作。 你可以通过以下方式打开命令提示符: 1. **开始...

    SQLPrompt6.0 SQL格式化智能提示工具

    SQLPrompt6.0 SQL格式化智能提示工具,内容包括安装包,注册机,注册说明。详情你参考注册说明,注册时请断开网络

    SQL Prompt

    SQL Server智能化提示插件!

    prompt:node.js的漂亮命令行提示符

    node.js的漂亮命令行提示符 特征 提示用户输入 支持验证和默认值 隐藏密码 用法 使用提示相对简单。 您应该了解两种核心方法: prompt.get()和prompt.addProperties() 。 他们的方法除了用于复杂属性验证(以及更多...

    SQLPrompt快速参考指南(中文机翻word版)

    原英文文档:http://assets.red-gate.com/products/sql-development/sql-prompt/assets/sql-prompt-quick-reference.pdf,使用google翻译器机翻为中英文对照文档。

    SQLPrompt_7.2.2.273中文翻译及配置.7z

    SQLPrompt_7.2.2.273中文翻译及配置 所有翻译为中截屏图片配中文翻译,大部分加入了我使用中的理解 配置文件为我平时使用中常用配置

    ChatGPT定制化客户Prompt教程

    通过使用一些Prompt关键词,我们可以帮助你快速了解客户的需求和偏好,并提供个性化的建议和解决方案,提高客户满意度和忠诚度。本教程的目标是帮助你掌握使用ChatGPT进行定制化客户交流的方法。通过学习本教程,你...

    SQLPrompt_10.1.4完美支持SSMS18.5 详细文档

    SQL Prompt是一款拥有SQL智能提示功能的SQL Server和VS插件。SQL Prompt能根据数据库的对象名称,语法和用户编写的代码片段自动进行检索,智能的为用户提供唯一合适的代码选择。自动脚本设置为用户提供了简单的代码...

    PROMPT

    PROMPT

    SQL格式化_Prompt

    MSSQL的智能提示速度真的是不敢恭维,Prompt能够帮助我们解决这一问题,并有其他一些更便捷的功能等你发现分享!

    ChatGPT客服团队赋能高级提示词Prompt教程

    通过使用一些高级提示词Prompt,我们可以帮助客服人员快速解决问题,提供更好的客户体验。本教程的目标是帮助你掌握使用ChatGPT来赋能客服团队的方法。通过学习本教程,你的客服团队将能够更有效地利用ChatGPT,快速...

Global site tag (gtag.js) - Google Analytics