MySQL命令行用法参考
2017-12-18 11:02
134 查看
环境约定
基于mysql5.5参考资料
[1]. mysql 命令行你知多少, http://blog.51yip.com/mysql/1056.html选项用法
可以使用–help查询出mysql命令行支持的所有选项帮助信息
# 显示帮助并退出 -?, --help Display this help and exit. # 显示帮助的同义词 -I, --help Synonym for -?
提示信息
# 自动提示 --auto-rehash Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.(Defaults to on; use --skip-auto-rehash to disable.) 启用自动重复,一个不需要使用“rehash”把表和字段完成,但启动和重新连接可能需要更长的时间。禁用使用--disable-auto-rehash选项(默认是打开的,使用--skip-auto-rehash选项禁用)。 # 关闭自动提示 -A, --no-auto-rehash No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. 不启用自动提示,必须使用'rehash' 选项才能得到表和字段,这样可以更快的启动和禁用mysql再次连接。
在命令行执行sql语句
-e, --execute=name Execute command and quit. (Disables --force and history file.) # 执行命令并退出(禁用--force选项和历史文件) # 查询表结构生成html信息,并导出到a.htmla # 结合-e导出一个表的全部结构 -H -e "SELECT TABLE_NAME, COLUMN_NAME,COLUMN_DEFAULT, IS_NULLABLE, COLUMN_TYPE, COLUMN_KEY, EXTRA, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA='databasename';" > a.html # 只导出部分有用的结构 -H -e "SELECT COLUMN_NAME, COLUMN_TYPE, COLUMN_KEY, EXTRA, COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA='tasks' and TABLE_NAME='histories';" > b.html
导出为html或xml格式
可以配合-e选项,导出查询的sql语句,比如查询表结构和查询数据-H --html Produce HTML output. # 生成HTML输出。 -X, --xml Produce XML output. # 生成XML输出。
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- [知识点]mysql安装完,哇咔,初始密码百试不灵咋办!
- mysql-connector-java 6.x 切换 注意事项
- CentOS 7 两步安装启动Mysql(mariadb)
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- 解决mysql 开启logbin 导致存储过程报错
- MySQL 备份和恢复策略
- centos7 mysql数据库安装和配置
- mac下安装mysql(转载)