获取mysql有关的帮助信息,直接在mysql提示符下输入help即可获得有关在mysql客户端相关的帮助信息。这个方式与Oracle SQL*plus下的help 是类似的。mysql> help For information about MySQL products and services, visit:http://www.mysql.com/For developer information, including the MySQL Reference Manual, visit:http://dev.mysql.com/To buy MySQL Enterprise support, training, or other products, visit:https://shop.mysql.com/ List of all MySQL commands:Note that all text commands must be first on line and end with';' ? (\?) Synonymfor `help'.clear (\c) Clear the current input statement. --清除当前输入的语句connect (\r) Reconnect to the server. Optional arguments are db and host. --重新连接,通常用于被剔除或异常断开后重新连接,SQL*plus下也有这样一个connect命令delimiter (\d) Set statement delimiter. --设置命令终止符,缺省为;,比如我们可以设定为/来表示语句结束edit (\e) Editcommand with $EDITOR. --编辑缓冲区的上一条SQL语句到文件,缺省调用vi,文件会放在/tmp路径下ego (\G) Sendcommand to mysql server, display result vertically. --控制结果显示为垂直显示exit (\q) Exit mysql. Same as quit. --退出mysqlgo (\g) Sendcommand to mysql server. --发送命令到mysql服务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. --设置pager方式,可以设置为调用more,less等等,主要是用于分页显示print (\p) Print currentcommand.prompt (\R) Change your mysql prompt. --改变mysql的提示符quit (\q) Quit mysql.rehash (\#) Rebuild completion hash. --自动补齐相关对象名字source (\.) Execute an SQL scriptfile. Takes afile name as an argument. --执行脚本文件status (\s) Get status information from the server. --获得状态信息system (\!) Execute a system shellcommand. --执行系统命令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 neededfor processing binlog with multi-byte charsets. --设置字符集warnings (\W) Show warnings after every statement. --打印警告信息nowarning (\w) Don't show warnings after every statement.--上面的所有命令,扩号内的为快捷操作,即只需要输入“\”+ 字母即可执行 For server side help,type 'help contents' --注意这里的描述help contents将获得服务器端的相关帮助信息 --演示部分,演示常用命令--connect命令mysql> connect chardb localhost;Reading table informationfor completion of table and column namesYou can turn off this feature to get a quicker startup with -A Connectionid: 5Current database: chardb --设置分页,在多余一个页面显示时会不停的翻滚,用该命令可以设置分页,设置为调用系统命令mysql> pagermore --设置为more方式PAGERset to'more'mysql>select table_name,table_type,engine from information_schema.tables; --该查询会超出一屏显示后按空格键会自动翻滚到下一屏mysql> pagertail -5; --设置输出尾部5行PAGERset to'tail -5'mysql>select table_name,table_type,engine from information_schema.tables;| setup_timers | BASE TABLE | PERFORMANCE_SCHEMA || threads | BASE TABLE | PERFORMANCE_SCHEMA || animals | BASE TABLE | InnoDB || shop | BASE TABLE | InnoDB |+----------------------------------------------+-------------+--------------------+92 rowsin set (0.02 sec) mysql> pager; --查看当前的pager设置PAGERset to'tail -5'mysql> nopager; --切换到标准(缺省)pager方式PAGERset to stdout --tee命令,输出日志文件mysql>tee /tmp/query.log --开启输出到文件,相当与SQL*plus下的spoolLogging tofile '/tmp/query.log'mysql>select table_name,table_type,engine from information_schema.tables;+----------------------------------------------+-------------+--------------------+| table_name | table_type | engine |+----------------------------------------------+-------------+--------------------+| CHARACTER_SETS | SYSTEM VIEW | MEMORY || COLLATIONS | SYSTEM VIEW | MEMORY |.............mysql> notee; --关闭输出到文件,相当于SQL*Plus下的spool offOutfile disabled.mysql> systemtail /tmp/query.log --查看输出的日志文件| setup_consumers | BASE TABLE | PERFORMANCE_SCHEMA || setup_instruments | BASE TABLE | PERFORMANCE_SCHEMA || setup_timers | BASE TABLE | PERFORMANCE_SCHEMA || threads | BASE TABLE | PERFORMANCE_SCHEMA || animals | BASE TABLE | InnoDB || shop | BASE TABLE | InnoDB |+----------------------------------------------+-------------+--------------------+92 rowsin set (0.02 sec) --改变mysql提示符mysql> prompt SessionA>PROMPTset to'SessionA> ' --恢复到缺省提示符SessionA> prompt;Returning to default PROMPT of mysql> --执行sql脚本文件mysql> systemmore query.sql --注意,此时为当前目录use chardbselect * from tb_isam;mysql>source query.sqlReading table informationfor completion of table and column namesYou can turn off this feature to get a quicker startup with -A Database changed+------+-------+|id | value |+------+-------+| 1 | a || 2 | b || 3 | c || 4 | f |+------+-------+4 rowsin set (0.00 sec) --获取状态信息mysql> status;--------------mysql Ver 14.14 Distrib 5.5.37,for Linux (x86_64) using readline 5.1 Connectionid: 6Current database: chardbCurrent user: root@localhostSSL: Notin useCurrent pager:lessUsing outfile:''Using delimiter: ;Server version: 5.5.37-log MySQL Community Server (GPL)Protocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: utf8Client characterset: latin1Conn. characterset: latin1UNIX socket:/var/lib/mysql/mysql.sockUptime: 3 hours 10 min 59 sec Threads: 1 Questions: 97 Slow queries: 0 Opens: 313 Flush tables: 1 Open tables: 51 Queries per second avg: 0.008-------------- --修改客户端字符集mysql> charset gbk;Charset changedmysql> \s--------------mysql Ver 14.14 Distrib 5.5.37,for Linux (x86_64) using readline 5.1 Connectionid: 6Current database: chardbCurrent user: root@localhostSSL: Notin useCurrent pager:lessUsing outfile:''Using delimiter: ;Server version: 5.5.37-log MySQL Community Server (GPL)Protocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: utf8Client characterset: gbk ---客户端和conn端字符集都变成gbk了。Conn. characterset: gbkUNIX socket:/var/lib/mysql/mysql.sockUptime: 3 hours 13 min 33 sec Threads: 1 Questions: 105 Slow queries: 0 Opens: 313 Flush tables: 1 Open tables: 51 Queries per second avg: 0.009-------------- mysql> warnings;Show warnings enabled.mysql> selecs 1;ERROR 1064 (42000): You have an errorin your SQL syntax; check the manual that corresponds to your MySQL server versionfor the right syntax to use near'selecs 1' at line 1mysql> show warnings;+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------+| Level | Code | Message |+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------+| Error | 1064 | You have an errorin your SQL syntax; check the manual that corresponds to your MySQL server versionfor the right syntax to use near'selecs 1' at line 1 |+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------+1 rowin set (0.00 sec) mysql> show errors;+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------+| Level | Code | Message |+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------+| Error | 1064 | You have an errorin your SQL syntax; check the manual that corresponds to your MySQL server versionfor the right syntax to use near'selecs 1' at line 1 |+-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------+1 rowin set (0.00 sec) mysql> nowarning;Show warnings disabled.
mysql help_Mysql help命令(帮助信息)中文注解
最新推荐文章于 2021-11-05 15:14:24 发布