mysql -prompt选项

原文:http://www.cnblogs.com/abclife/p/5632826.html

使用-pormpt修改提示符。可以在登录时或者在登录后使用prompt选项来修改提示符

(1)使用mysql命令行参数修改提示符

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 5.6.25 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.
 
mysql>
 
# mysql -uroot -p --prompt="\\u@\\h:\\d \\r:\\m:\\s>" 
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.6.25 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@localhost:(none) 10:05:25>use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
root@localhost:test 10:05:31>

(2)修改配置文件/etc/my.cnf

1
2
[mysql]
prompt="\\u@\\h:\\d \\r:\\m:\\s>"

(3)在 MySQL 中使用 prompt 命令

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

(4)当然可以在在Bash层修改 MYSQL_PS1变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# export MYSQL_PS1="(\u@\h) [\d]> "
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.6.25 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@localhost) [(none)]> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
(root@localhost) [test]>

参数辅助说明

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.1.12)
\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选项的更多相关文章

  1. mysql -prompt选项

    使用-pormpt修改提示符.可以在登录时或者在登录后使用prompt选项来修改提示符 (1)使用mysql命令行参数修改提示符 # mysql -u root -p Enter password: ...

  2. mysql --prompt

    mysql --prompt修改命令行链接mysql时的提示符,shell脚本示例如下 #!/bin/bash in crm) cmd='mysql -h192.168.1.2 -uroot -pro ...

  3. [转] mysql --prompt介绍

    mysql --prompt修改命令行链接mysql时的提示符,shell脚本示例如下 #!/bin/bash case $1 in crm) cmd='mysql -h192.168.1.2 -ur ...

  4. mysql prompt的用法详解

    prompt命令可以在mysql提示符中显示当前用户.数据库.时间等信息 代码如下: mysql -uroot -p --prompt="\\u@\\h:\\d \\r:\\m:\\s> ...

  5. MySQL binlog-do-db选项是危险的

    很多人通过 binlog-do-db, binlog-ignore-db, replicate-do-db 和   replicate-ignore-db 来过滤复制(某些数据库), 尽管有些使用, ...

  6. MySQL binlog-do-db选项是危险的[转]

    很多人通过 binlog-do-db, binlog-ignore-db, replicate-do-db 和   replicate-ignore-db 来过滤复制(某些数据库), 尽管有些使用, ...

  7. 监控mysql各种选项

    安装mysql之后,需要对mysql服务进行监控.   nagios开源自带的check_mysql 对 mysql 的slave 机监控倒是不错.但是对数据库主机监控就略显不足了.   使用一个监控 ...

  8. MySQL read_only选项的作用

    1作用: 从字面意思上看就可以知道这个是把mysql设置为只读,但是这个只读只是针对一般用户而言的,对于root这种用super权限的用户read_only是没有用的. 2设置方式: set glob ...

  9. MySQL prompt命令

    修改提示符,设置后挺方便的 例如: 几个好用的参数 \d 当前数据库 \u 当前用户 \h 当前主机 更多参数可以参考mysol官方文档 参考文档:https://dev.mysql.com/doc/ ...

随机推荐

  1. Web前后端数据交换技术和规范发展史:Form、Ajax、Comet、Websocket

    第一阶段:Form web应用想要与服务器交互,必须提交一个表单(form).服务器接收并处理该表单,然后返回一个全新的页面. 缺点:前后两个页面需要更新的数据可能很少,这个过程可能传输了很多之前那个 ...

  2. Redis Quick Start [熟练版]

    一.下载解压 wget http://download.redis.io/redis-stable.tar.gztar xvzf redis-stable.tar.gzcd redis-stable ...

  3. 再议GCC编译时的静态库依赖次顺问题

    假设有如三个源代码文件: $ cat a.cpp void a() { } $ cat b.cpp extern void a(); void b() { a(); // 调用a.cpp中的a() } ...

  4. [label][Google-Developers] Your First Multi Screen Site

    内容是任何网站最重要的部分. 所以,让我们为内容而设计,而不要让设计支配内容. 1. 首先确定我们需要的内容: 2. 基于这个内容,为无论宽.窄的 viewport 创建一个页面结构: 3. 然后在简 ...

  5. WPF Image显示图片,文件被占用异常

    imageControl.Source = this.GetBitmapImage(imagePath);//imageControl为WPF Image控件 public BitmapImage G ...

  6. django系列5.2--ORM数据库的单表操作

    单表操作 在views.py中添加对数据库的操作语句 #在逻辑代码中导入你要操作的表 from app import models def add_book(request): ''' 添加表记录 : ...

  7. composer 学习与推荐资料

    今天看了一下composer,前几天开始用包依赖,以前一直都是自己手动配.今天用了composer,要学习的话可以按照以下链接学习: 1 官方文档: http://docs.phpcomposer.c ...

  8. 视频video遇到一些坑

    1.video层级最高问题 解决方案思路:当点击其他按钮触发事件时,视频层级挡住其他外层,比如会挡住弹窗,这是应该让视频暂停播放且隐藏,这是视频这个地方会空一个位置可以放一张封面占位,这样就解决视频层 ...

  9. BruteXSS(汉化版)

    BruteXSS是一个非常强大和快速的跨站点脚本暴力注入.它用于暴力注入一个参数.该BruteXSS从指定的词库加载多种有效载荷进行注入并且使用指定的载荷和扫描检查这些参数很容易受到XSS漏洞.得益于 ...

  10. Linux中一些 不是很常用的配置修改

    1,让虚拟机屏幕最大化 :查看-->自动调整大小-->自动适应客户机 2,让虚拟机取消屏保: system --> preferences --> Screensaver