bitscn.com
mysql入门学习之十六:mysql命令参数详解
相关链接:
mysql入门学习之一:基本操作
http:///database/201212/173868.html
mysql入门学习之二:使用正则表达式搜索
http:///database/201212/173869.html
mysql入门学习之三:全文本搜索
http:///database/201212/173873.html
mysql入门学习之四:mysql的数据类型
http:///database/201212/175536.html
mysql入门学习之五:mysql的字符集
http:///database/201212/175541.html
mysql入门学习之六:mysql的运算符
http:///database/201212/175862.html
mysql入门学习之七:mysql常用函数
http:///database/201212/175864.html
mysql入门学习之八:数据库及表的基本操作
http:///database/201212/175867.html
mysql入门学习之九:索引的简单操作
http:///database/201212/176772.html
mysql入门学习之十:视图的基本操作
http:///database/201212/176775.html
mysql入门学习之十一:触发器的基本操作
http:///database/201212/176781.html
mysql入门学习之十二:存储过程的基本操作
http:///database/201212/177380.html
mysql入门学习之十三:自定义函数的基本操作
http:///database/201212/177382.html
mysql入门学习之十四:游标的基本操作
http:///database/201212/177384.html
mysql入门学习之十五:事务处理的基本操作
http:///database/201212/177385.html
一、mysql命令行参数的详细说明
usage:mysql [options] [database]
下面为各选项的详细说明:
-?, --help
显示帮助信息并退出
-i, --help
显示帮助信息并退出
--auto-rehash
自动补全功能,就像linux里面,按tab键出提示差不多
-a, --no-auto-rehash
默认状态是没有自动补全功能的。-a就是不要自动补全功能
-b, --batch
mysql不使用历史文件,禁用交互
--character-sets-dir=name
字体集的安装目录
--default-character-set=name
设置数据库的默认字符集
--column-type-info
结果集返回时,同时显示字段的类型等相关信息
-c, --comments
preserve comments. send comments to the server. the
default is --skip-comments (discard comments), enable
with --comments
-c, --compress
在客户端和服务器端传递信息时使用压缩
-#, --debug[=#]
bug调用功能
-d, --database=name
使用哪个数据库
--default-character-set=name
设置默认的字符集
--delimiter=name
设置默认命令结束符
-e, --execute=name
执行mysql的sql语句
-e, --vertical
垂直打印查询输出
-f, --force
如果有错误跳过去,继续执行下面的
-g, --named-commands
enable named commands. named commands mean this program's
internal commands; see mysql> help . when enabled, the
named commands can be used from any line of the query,
otherwise only from the first line, before an enter.
disable with --disable-named-commands. this option is
disabled by default.
-g, --no-named-commands
named commands are disabled. use /* form only, or use
named commands only in the beginning of a line ending
with a semicolon (;) since version 10.9 the client now
starts with this option enabled by default! disable with
'-g'. long format commands still work from the first
line. warning: option deprecated; use
--disable-named-commands instead.
-i, --ignore-spaces
忽视函数名后面的空格.
--local-infile
启动/禁用load data local infile.
-b, --no-beep
sql错误时,禁止嘟的一声
-h, --host=name
设置连接的服务器名或者ip
-h, --html
以html的方式输出
-x, --xml
以xml的方式输出
--line-numbers
显示错误的行号
-l, --skip-line-numbers
忽略错误的行号
-n, --unbuffered
每执行一次sql后,刷新缓存
--column-names
查寻时显示列信息,默认是加上的
-n, --skip-column-names
不显示列信息
-o, --set-variable=name
设置变量用法是--set-variable=var_name=var_value
--sigint-ignore
忽视sigint符号(登录退出时control-c的结果)
-o, --one-database
忽视除了为命令行中命名的默认数据库的语句。可以帮跳过日志中的其它数据库的更新。
--pager[=name]
使用分页器来显示查询输出,这个要在linux可以用more,less等。
--no-pager
不使用分页器来显示查询输出。
-p, --password[=name]
输入密码
-w, --pipe
use named pipes to connect to server.
-p, --port=#
设置端口
--prompt=name
设置mysql提示符
--protocol=name
设置使用的协议
-q, --quick
不缓存查询的结果,顺序打印每一行。如果输出被挂起,服务器会慢下来,mysql不使用历史文件。
-r, --raw
写列的值而不转义转换。通常结合--batch选项使用。
--reconnect
如果与服务器之间的连接断开,自动尝试重新连接。禁止重新连接,使用--disable-reconnect。
-s, --silent
一行一行输出,中间有tab分隔
-s, --socket=name
连接服务器的sockey文件
--ssl
激活ssl连接,不激活--skip-ssl
--ssl-ca=name
ca file in pem format (check openssl docs, implies
--ssl).
--ssl-capath=name
ca directory (check openssl docs, implies --ssl).
--ssl-cert=name
x509 cert in pem format (implies --ssl).
--ssl-cipher=name
ssl cipher to use (implies --ssl).
--ssl-key=name
x509 key in pem format (implies --ssl).
--ssl-verify-server-cert
连接时审核服务器的证书
-t, --table
以表格的形式输出
--tee=name
将输出拷贝添加到给定的文件中,禁时用--disable-tee
--no-tee
根--disable-tee功能一样
-u, --user=name
用户名
-u, --safe-updates
only allow update and delete that uses keys.
-u, --i-am-a-dummy
synonym for option --safe-updates, -u.
-v, --verbose
输出mysql执行的语句
-v, --version
版本信息
-w, --wait
服务器down后,等待到重起的时间
--connect_timeout=#
连接前要等待的时间
--max_allowed_packet=#
服务器接收/发送包的最大长度
--net_buffer_length=#
tcp/ip和套接字通信缓冲区大小。
--select_limit=#
使用--safe-updates时select语句的自动限制
--max_join_size=#
使用--safe-updates时联接中的行的自动限制
--secure-auth
拒绝用(pre-4.1.1)的方式连接到数据库
--server-arg=name
sendembeddedserverthisasaparameter.
--show-warnings
显示警告
二、部分使用示例
[sql]
c:/users/qxl>mysql -uroot -d test -e show tables;
+-----------------------+
| tables_in_test |
+-----------------------+
| newname |
| productnotes |
| student |
| t_goods |
c:/users/qxl>mysql -uroot -d test -e show tables; -b
tables_in_test
newname
productnotes
student
t_goods
c:/users/qxl>mysql -uroot -d test --default-character-set=gbk
welcome to the mysql monitor. commands end with ; or /g.
your mysql connection id is 20
server version: 5.1.28-rc-community mysql community server (gpl)
type 'help;' or '/h' for help. type '/c' to clear the buffer.
mysql> show variables like '%char%';
+--------------------------+------------------------------------------+
| variable_name | value |
+--------------------------+------------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | d:/apmserv5.2.6/mysql5.1/share/charsets/ |
+--------------------------+------------------------------------------+
c:/users/qxl>mysql -uroot -d test --delimiter=//
welcome to the mysql monitor. commands end with ; or /g.
your mysql connection id is 21
server version: 5.1.28-rc-community mysql community server (gpl)
type 'help;' or '/h' for help. type '/c' to clear the buffer.
mysql> use test//
database changed
mysql> select count(*) from test.newname//
c:/users/qxl>mysql -uroot -d mysql -e show tables; -h
tables_in_mysql
columns_priv
db
tr>
event func
general_log
help_category /tr>
help_keyword
help_relation
help_topic
>host
ndb_binlog_index
plugin
proc
td>procs_priv
servers
slow_log
tables_priv tr>
time_zone
time_zone_leap_second
time_zone_name
>
time_zone_transition
time_zone_transition_type
user /tr>
c:/users/qxl>mysql -uroot -d mysql -e show tables; -x
columns_priv
db
event
func
c:/users/qxl>mysql -uroot -d mysql --prompt=this is my database!
welcome to the mysql monitor. commands end with ; or /g.
your mysql connection id is 27
server version: 5.1.28-rc-community mysql community server (gpl)
type 'help;' or '/h' for help. type '/c' to clear the buffer.
this is my database!
bitscn.com
