mysql>命令行下可以使用的各种命令解析(使用help或者help contents查看更多信息) ...

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/liujianguangaaa/article/details/83916349

mysql -u root -p
进入到mysql客户端应用程序mysql,通过它可以管理数据库

,访问数据库,执行SQL语句等等。

1. 获取帮助
mysql>help或者/?

2. 将在mysql>下输入的内容输出到文件中,使用
mysql>tee filename或者\T filename
mysql会提示你已经logging to file 'filename' 
这样在mysql>下输入的命令及输出结果就会都保存到filename文件中
如果想取消挂载,输入 notee或者\t
mysql会提示outfile disabled

在进入mysql之前,也可以通过选项--tee或者--no-tee挂载外部文件或者取消
mysql -u root -p --tee outfile 
或者
mysql -u root -p --no-tee 

3. 
mysql>tee mysql_help.txt
将输出挂载到mysql_help.txt文件上
输入mysql>help显示输出信息

mysql> help

For information about MySQL products and services, visit:
   < type="text/javascript"> http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit: 
   http://dev.mysql.com/
To buy MySQL Network 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 ';'

?         (\?) Synonym for `help'. 
help      (\h) Display this help.

clear     (\c) Clear command.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter. 
ego       (\G) Send command to mysql server, display result vertically.

go        (\g) Send command to mysql server.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
notee     (\t) Don't write into outfile.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.

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. 

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. < type="text/javascript"> 
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.

exit      (\q) Exit mysql. Same as quit.
quit      (\q) Quit mysql.


For server side help, type 'help contents' 

4. 常用命令示例

a. mysql>?或者help

b. mysql> show databases \G
*************************** 1. row ***************************
Database: information_schema
*************************** 2. row *************************** 
Database: broker
*************************** 3. row ***************************
Database: gene2pubmed
*************************** 4. row ***************************
Database: mysql
*************************** 5. row *************************** 
Database: test
5 rows in set (0.00 sec)

c. 
mysql>tee [outfile]    不输入outfile,则使用上次挂载的文件
mysql>notee    取消挂载

d. mysql>status    显示状态信息

e. mysql>use database_name

f. 
定义一个文件sql_script,内容为sql语句,使用source执行文件中的sql script
如sql_script文件中保存show databases;
mysql>source sql_script
会显示sql_script中show databases;执行的结果

此外注意,获取server side的帮助可以使用 help contents命令


mysql>下输入help contents查询各种帮助。
当要完成某项功能的时候,又不知道该用哪个命令的时候可以在mysql>下输入help contents查询帮助文档,了解各个命令的功能。 

2. 
mysql>help contents获取查询结果

mysql> help contents
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the following 
categories:
   Account Management
   Administration
   Data Definition
   Data Manipulation
   Data Types
   Functions
   Functions and Modifiers for Use with GROUP BY
   Geographic Features
   Language Structure
   Storage Engines 
   Stored Routines
   Table Maintenance
   Transactions
   Triggers

//如下highlight的命令为常用命令,通过help item_name可以查看其具体功能

帐号管理 
mysql> help account management
You asked for help about help category: " Account Management"
For more information, type 'help <item>', where <item> is one of the following
topics:
   CREATE USER
//创建一个用户
   DROP USER
//删除一个用户

   GRANT
//为用户赋予权限
   RENAME USER
   REVOKE
   SET PASSWORD
//为某个用户设置帐户

数据库管理
mysql> help administration
You asked for help about help category: " Administration"
For more information, type 'help <item>', where <item> is one of the following
topics:
   DESCRIBE
//描述信息,可以用它输出数据表结构,help DESCRIBE查看更多信息
   FLUSH QUERY CACHE
   HELP COMMAND
   HELP STATEMENT

数据定义
mysql> help data definition
You asked for help about help category: "Data Definition"
For more information, type 'help <item>', where <item> is one of the following 
topics:
   ALTER DATABASE
//修改数据库
   ALTER TABLE
//修改数据表结构
   ALTER VIEW
   CONSTRAINT
   CREATE DATABASE
//创建一个数据库
   CREATE INDEX
//创建一个索引,help create index了解更多
   CREATE TABLE
//创建一个数据表
   CREATE VIEW
   DROP DATABASE 
   DROP INDEX
   DROP TABLE
   DROP VIEW
   MERGE
   RENAME TABLE

数据操作
mysql> help data manipulation
You asked for help about help category: " Data Manipulation"
For more information, type 'help <item>', where <item> is one of the following
topics:
   CACHE INDEX
   CHANGE MASTER TO
   DEALLOCATE PREPARE
   DELETE
   DO
   DUAL
   EXECUTE STATEMENT
   EXPLAIN

Syntax:
EXPLAIN tbl_name
//等同于DESCRIBE table_name,显示数据表定义结构
Or:
EXPLAIN [EXTENDED] SELECT select_options
//显示MySQL执行SELECT语句的细节,方便采取优化策略

The EXPLAIN statement can be used either as a synonym for DESCRIBE or as a way to obtain information about how MySQL executes a SELECT statement:
o EXPLAIN tbl_name is synonymous with DESCRIBE tbl_name or SHOW COLUMNS FROM tbl_name.
o When you precede a SELECT statement with the keyword EXPLAIN, MySQL displays information from the optimizer about the query execution plan. That is, MySQL explains how it would process the SELECT, including information about how tables are joined and in which order.

   FLUSH
   HANDLER
   INSERT
//插入数据
   INSERT DELAYED
   INSERT SELECT
//使用INSERT SELECT可以将从一个或多个数据表SELECT的结果插入到另一个表格中

   JOIN
//MySQL中的多表连接操作,详细情况help join

   KILL
//客户端连接到mysql的server即mysqld,都是独立的线程thread,通过show processlist可以查看连接到mysqld server的各个线程的id,通过kill可以结束当前连接(CONNECTION)或者查询(QUERY)的线程 

   LOAD DATA
//从指定目录导入数据,help load data了解更多信息

   LOAD DATA FROM MASTER
   LOAD INDEX
   LOAD TABLE FROM MASTER 
   PREPARE
   PURGE MASTER LOGS
   REPLACE INTO
   RESET
   RESET MASTER
   RESET SLAVE
   SELECT
//SELECT除了用于从数据库中检索满足所定义条件的制定列之外,还可以返回和任何table都无关的数据信息,如SELECT 1+1 

   SET

   SET GLOBAL SQL_SLAVE_SKIP_COUNTER
   SET SQL_LOG_BIN

SHOW has many forms that provide information about databases, tables, 
columns, or status information about the server. This section describes 
//MySQL的SHOW功能很强大,通过help show可以查看更加详细的功能,显示数据库,数据表以及列,以及Server的状态信息
   SHOW
   SHOW BINARY LOGS
   SHOW BINLOG EVENTS
   SHOW CHARACTER SET
   SHOW COLLATION
   SHOW COLUMNS
   SHOW CREATE DATABASE
   SHOW CREATE PROCEDURE
   SHOW CREATE TABLE
   SHOW CREATE VIEW
   SHOW DATABASES
   SHOW ENGINE
   SHOW ENGINES 
   SHOW ERRORS
   SHOW GRANTS
   SHOW INDEX
   SHOW INNODB STATUS
   SHOW LOGS
   SHOW MASTER STATUS
   SHOW MUTEX STATUS
   SHOW OPEN TABLES
   SHOW PRIVILEGES
   SHOW PROCEDURE CODE
   SHOW PROCEDURE STATUS 
   SHOW PROCESSLIST
   SHOW PROFILES
   SHOW SLAVE HOSTS
   SHOW SLAVE STATUS
   SHOW STATUS
   SHOW TABLE STATUS
   SHOW TABLES
   SHOW TRIGGERS
   SHOW VARIABLES
   SHOW WARNINGS
   START SLAVE 
   STOP SLAVE
   TRUNCATE TABLE
   UNION
   UPDATE

MySQL支持的数据类型
mysql> help data types
You asked for help about help category: "Data Types"
For more information, type 'help <item>', where <item> is one of the following 
topics:
   AUTO_INCREMENT
   BIGINT
   BINARY
   BIT
   BLOB
   BLOB DATA TYPE
   BOOLEAN
   CHAR
   CHAR BYTE
   DATE
   DATETIME
   DEC
   DECIMAL 
   DOUBLE
   DOUBLE PRECISION
   ENUM
   FLOAT
   INT 
   INTEGER
   LONGBLOB
   LONGTEXT
   MEDIUMBLOB
   MEDIUMINT
   MEDIUMTEXT
   SET DATA TYPE
   SMALLINT
   TEXT
   TIME
   TIMESTAMP
   TINYBLOB
   TINYINT 
   TINYTEXT
   VARBINARY
   VARCHAR
   YEAR DATA TYPE

函数
mysql> help functions
You asked for help about help category: " Functions"
For more information, type 'help <item>', where <item> is one of the following
topics:
   CREATE FUNCTION
   DROP FUNCTION
   PROCEDURE ANALYSE
categories:
   Bit Functions 
   Comparison operators
   Control flow functions
   Date and Time Functions
   Encryption Functions
   Information Functions
   Logical operators
   Miscellaneous Functions
   Numeric Functions
   String Functions

等等更多

< type="text/javascript">
展开阅读全文

Help!Help!Help!Help!Help!Help!

06-27

我写了一个代码,出现一个问题,不知道出在哪,请大虾们指点一下:rn代码:rnString sql="select * from DGZ_Admin order by ID ";rnString sDBDriver="com.microsoft.jdbc.sqlserver.SQLServerDriver";rn String sConnStr ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=topicnews;user=sa;password=zhh";rn try rn rn Class.forName(sDBDriver);rn rn catch(ClassNotFoundException e)rn rn System.out.println("无法建立数据库连接!:"+e.getMessage());rn rn Connection conn= DriverManager.getConnection(sConnStr);rn Statement stmt=conn.createStatement();rn ResultSet rs=stmt.executeQuery(sql);rn rs.last();??????????????出问题的地方rn错误提示:org.apache.jasper.JasperException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.lastrn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)rn at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)rn at java.lang.Thread.run(Thread.java:536)rnrnrnroot cause rnrnjavax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.lastrn at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)rn at org.apache.jsp.Admin_UserList_jsp._jspService(Admin_UserList_jsp.java:219)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rn at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)rn at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)rn at java.lang.Thread.run(Thread.java:536)rnrn 论坛

没有更多推荐了,返回首页