Chinaunix首页 | 论坛 | 博客
  • 博客访问: 460976
  • 博文数量: 237
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 0
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-12 14:40
个人简介

  每个人生的当口,都是会有一个孤独的时刻,四顾无人,只有自己,于是不得不看明白自己的脆弱,自己的欲望,自己的念想,自己的界限,还有,自己真正的梦想。

文章分类

全部博文(237)

文章存档

2017年(3)

2016年(234)

分类: Mysql/postgreSQL

2016-05-11 11:12:09

原文地址:修改MySQL命令提示符 作者:ning_lianjie

当前session可以直接用prompt修改

mysql> prompt \D

PROMPT set to '\D'

Mon May 30 12:31:28 2011

mysql>prompt \u@\h \d \r:\m:\s>     

PROMPT set to '\u@\h \d \r:\m:\s>'

root@localhost (none) 12:50:40>

还可以在my.cnf配置文件中[mysql]添加(注意不是[mysqld]),加在配置文中后,不需要重启mysql,退出session,重新登录即可。

如果在my.cnf配置文件中最好用\\,避免转义带来的问题。

[mysql]

prompt=\\u@\\h \\d \\r:\\m:\\s> 

 

关于\U(\h)The server host的一些测试

msyql.user表如下

+-------------+-------------+

| user        | host        |

+-------------+-------------+

| replication | %           |

| root        | 127.0.0.1   |

|             | localhost   |

| root        | localhost   |

|             | ora01.dh.cn |

| repli       | ora01.dh.cn |

| root        | ora01.dh.cn |

+-------------+-------------+

# mysql -h192.168.60.134 -P3308

mysql> prompt \U

PROMPT set to '\U'

root@ora01.dh.cn

# mysql -h127.0.0.1 -P3308    

mysql> prompt \U

PROMPT set to '\U'

root@localhost

# mysql -S mysql3.sock

mysql> prompt \U

PROMPT set to '\U'

root@localhost

结论,提示符中的h参数,与mysql连接时的socket或者tcp有关系。

 

shell>man 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                            |

       +-------+--------------------------------------------------+

       |\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          |

       +-------+--------------------------------------------------+

阅读(396) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~