mysql提示符prompt的用法

2022-05-27 08:09:10 字數 2198 閱讀 1798

隨著管理mysql伺服器越來越多,同樣的mysql>的提示符有可能會讓你輸入錯誤的命令到錯誤的資料庫,這時候需要巧用mysql的提示符,這 是我的提示符root@localhost(mysql) 08:55:21> 用prompt命令實現(適用於windows和linux環境)

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

\u:連線使用者

\h:連線主機

\d:連線資料庫

\r:\m:\s:顯示當前時間

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

root@localhost(mysql) 08:55:21> status

設定方式=>

<1>mysql -uroot -p --prompt="(\\u@\\h)[\\d] \\r:\\m:\\s>"

<2>mysql> prompt (\u@\h)[\d]\r:\m:\s>

<3>也可以在在my.cnf配置檔案裡進行配置:

[mysql]/[client]

prompt="(\\u@\\h)[\\d] \\r:\\m:\\s>"

default-character-set=utf8 

附: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

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

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

\uwww.2cto.com  

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

zsh 命令提示符 PROMPT

使用上zsh後,發現命令提示符顯示不了當前的路徑,和一般的linux系統預設提示不一致。配置自己的提示符 更改配置檔案.zshrc,新增配置prompt m 重新開啟乙個視窗生效。乙個 乙個 y 當前的tty名 l 當前的tty名,如 pts 1 m 完整主機名 m 主機名 在第乙個句號之前截斷 n...

mysql提示符是什麼 MySQL提示符

下表顯示出可以看見的各個提示符並簡述它們所表示的mysql的狀態 提示符含義 mysql 準備好接受新命令。等待多行命令的下一行。等待下一行,等待以單引號 開始的字串的結束。等待下一行,等待以雙引號 開始的字串的結束。等待下一行,等待以反斜點 開始的識別符的結束。等待下一行,等待以 開始的注釋的結束...

mysql提示符詳解 MySQL提示符含義

標籤 mysql 準備好接受新命令。說明 正常等待輸入的提示符。等待多行命令的下一行。說明 這是將乙個sql語句分多行輸入時的提示。前提是你輸入了乙個不以分號結尾的sql語句。等待下一行,等待以單引號 開始的字串的結束。說明 前面你應該是已經輸入了乙個單引號,並且此單引號沒有結束,系統等待你輸入另乙...