mysql更改开头的命令提示_修改MySQL命令提示符

当前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          |

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值