在my.cnf 的 mysql 端 添加如下設置
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
prompt="(\u:mysql1@linuxbyte.org \R:\m)[\d]: "
會產生如下效果:
root@ubuntu:/home/hew# mysql -u hew -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 320
Server version: 5.1.41-3ubuntu12.1 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(hew:mysql1@linuxbyte.org 21:12)[(none)]: use linuxbyte #注意這里
Database changed
(hew:mysql1@linuxbyte.org 21:13)[linuxbyte]: use linuxsky; #這里
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
(hew:mysql1@linuxbyte.org 21:13)[linuxsky]: #這里
如上所示我們可以在mysql命令行下顯示當前的mysql 用戶,所在主機,時間和所用的數據庫。
這個在關鍵時刻可以讓我們避免很多誤操作。
原文轉自:http://blogread.cn/it/article/1605