mysql提示符命令prompt

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Nick_666/article/details/77538817

一句话总计:prompt命令可以在mysql提示符中显示随心所欲信息


\h: 服务器名称

\u: 用户名

\d: 数据库名称

\D: 日期


例子:

zjy@ubuntu:~$ mysql -uroot -proot --prompt '\h'

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 5.7.19-0ubuntu0.16.04.1 (Ubuntu)


Copyright (c) 2000, 2017, 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.


localhost

localhostprompt this_is_mysql

PROMPT set to 'this_is_mysql'

this_is_mysqlprompt \h

PROMPT set to '\h'

localhostprompt \u@\h \d \D>

PROMPT set to '\u@\h \d \D>'

root@localhost (none) Thu Aug 24 18:39:01 2017>prompt \u@\h \d>

PROMPT set to '\u@\h \d>'

root@localhost (none)>CREATE DATABASE IF NOT EXISTS test;

Query OK, 1 row affected (0.00 sec)


root@localhost (none)>USE test;

Database changed

root@localhost test>\q;

Bye


阅读更多
换一批

没有更多推荐了,返回首页