006-LAMP_MySQL_client
2016-01-19 14:37
495 查看
006-LAMP_MySQL_client
MySQL client options
命令行交互式客户端程序:mysql使用方法
[root@husa ~]# rpm -q mariadb mariadb-5.5.41-2.el7_0.x86_64 [root@husa ~]# man mysql
mysql mysql [OPTIONS] [database]
常用选项
--user=user_name, -u user_name:用户名,默认为root --host=host_name, -h host_name:Connect to the MySQL server on the given host.远程主机(即mysql服务器地址),注意这里是服务器的地址!,默认为localhost %:匹配任意长度的任意字符 172.16.%.%,172.16.0.0/16 _:匹配任意单个字符</font> --password[=password], -p[password]:username表示的用户的密码,默认为空 --ssl*:Options that begin with --ssl specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. --port=port_num, -P port_num:The TCP/IP port number to use for the connection. --default-character-set=utf8.:设置链接后使用的字符集 --execute=statement, -e statement:Execute the statement and quit.链接至服务器后并让其执行命令后直接返回,可用于shell脚本中 -Ddb_name:连接到服务器端后,设定此处指明的数据库为默认数据库
注意:mysql的用户账户由两部分组成:’USERNAME’@’HOST’;其中HOST用于限制此用户可通过哪些远程主机链接当前的mysql服务;HOST的表示方式,支持使用通配符
在bash中直接执行SQL语句
shell> mysql db_name < script.sql > output.tab
mysql链接到服务器后的相关控制
mysql>help? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. #\d CHAR:设定新的语句结束符 edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. #语句结束标记,结果垂直方式显示 exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. #语句结束标记 help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. # 退出 rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. #\u db_name: 设定哪个库为默认数据库 warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement.
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜
- MySQL 备份与恢复