mysql是MySQL提供的一个客户端工具,比较有特点的几个参数介绍如下:

-e 这个参数是在shell命令行执行参数后面的命令,而不是通过mysql登录到MySQL Server上
-H select 的结果按照html格式输出
-X select的结果按照xml格式输出

–prompt=name 设置mysql提示符,可以在提示符中显示主机,用户,database等,主要的几个变量为:
\v 服务器版本
\d 当前的数据库
\h 服务器主机
\p 当前的TCP/IP端口或套接字文件
\u 你的用户名
\U 你的全user_name@host_name账户名
\R 当前的时间,24-小时军用时间(0-23)
\r 当前的时间,标准12-小时(1-12)
\m 当前时间的分钟
\y 当前的年,两位
\Y 当前的年,四位
\D 当前的日期
\s 当前时间的秒
\w 当前周的天,3字符格式(Mon,Tue,…)
\P am/pm
\o 当前的月,数字格式
\O 当前的月,3字符格式(Jan,Feb,…)

–tee=name 把mysql输入和输出写道文件里,把操作过程记录下来方便以后查阅
–pager 可以用more分屏显示查询结果
–no-auto-rehash 禁止自动补齐

这些参数也可以写在/etc/my.cnf或者~/.my.cnf文件中[mysql]组中,有些也可以写在[client]组中,这样的话就不要在命令行里输入参数了。

我的mysql客户端配置:
~/.my.cnf
[client]
port=3306
socket=/tmt/mysql.sock
user=xxx
password=xxx
[mysql]
prompt="(\\u@\h \R:\m:\\s)[\\d]>"
pager="more"
tee="/tmp/query.log"
no-auto-rehash

登录mysql后显示:
Logging to file ‘/tmp/query.log’
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 150
Server version: 5.0.77 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

(tianjing@localhost 19:25:10)[(none)]>