`
liujianguangaaa
  • 浏览: 235096 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

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

阅读更多

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">

分享到:
评论

相关推荐

    Mysql命令帮助(使用help或者help contents)

    ### MySQL命令帮助详解 #### 一、概览 在MySQL中,用户可以通过多种方式获取帮助信息,例如使用`...通过使用`help`或`help contents`等命令,用户可以轻松地找到所需的帮助信息,从而更高效地进行数据库管理和操作。

    将MySQL help contents的内容有层次的输出方法推荐

    当需要在无法访问互联网的环境中查阅MySQL帮助时,可以通过MySQL客户端执行`help contents`命令来查看。然而,这种方式得到的输出通常是一维的,难以看出类目间的层级关系。例如,如果试图查找“backup table”命令...

    Mysql如何使用命令实现分级查找帮助详解

    contents`或`help contents`命令来查看MySQL提供的所有帮助类别。这两个命令是等价的,它们会列出一系列的分类,如Account Management、 Administration、Data Definition等。这些分类涵盖了MySQL的各个功能领域,...

    MySQL基础操作

    通过以上详细讲解,我们可以清晰地了解MySQL的基础操作,包括服务器的管理、基本的SQL命令、数据类型的使用、数据库和表的操作以及数据备份与恢复的方法。这些基础知识对于初学者来说至关重要,同时也是进行更复杂...

    MyEclipse6的使用

    - **获取帮助和阅读帮助文档**:使用 Help &gt; Help Contents。 - **CVS 团队源代码管理(在线阅读)**:使用 Team &gt; Share Project &gt; CVS。 **3.3 小结** 本章详细介绍了 Eclipse 的基本操作和配置方法,这对于高效...

    mysql学习笔记之帮助文档

    首先,`help`命令是MySQL客户端中的一个内置功能,它允许用户在不离开终端的情况下获取关于MySQL语法、函数、命令等的详细信息。要查看系统帮助的总览,你可以输入`help contents`。这会列出所有可用的帮助类别,如...

    PHP_help.rar_Help!_help.p

    PHP帮助文档资料是学习和掌握这一语言的重要资源,它涵盖了PHP技术的所有关键信息,包括基础语法、函数库、错误处理、对象和类、数据库交互等多个方面。下面我们将详细探讨这些知识点。 1. **基础语法**:PHP的基础...

    MySQL 5.6 Reference Manual

    Table of Contents Preface, Notes, Licenses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

    php手册200909版

    8. **XML和Web服务**:解析XML文档,使用SimpleXML或DOM扩展,以及与SOAP和RESTful Web服务的交互。 9. **安全性和性能优化**:手册也会涵盖如何防止SQL注入、XSS攻击,以及优化代码性能的方法。 10. **其他特性**...

    PHP.中文手册.chm

    CHM(Compiled Help Manual)格式使得这份手册可以离线查看,方便开发者在没有网络的情况下查阅。以下是基于这个压缩包文件中的主要知识点的详细解释: 1. **PHP**:PHP(Hypertext Preprocessor,超文本预处理器)...

    PHP.chm中文简体

    例如,使用mysqli或PDO_MYSQL扩展进行SQL查询,以及事务处理、预处理语句等高级特性。 错误处理和调试是开发者必备的技能,手册会介绍错误报告级别、异常处理、使用var_dump和debug_zval_dump等函数来分析变量状态...

    PHP5中文手册CHM版本

    你可以创建自己的类,定义属性和方法,实现继承和多态性,以更高效的方式组织代码。 2. **错误处理与异常**:PHP5引入了异常处理机制,使得程序在遇到错误时可以抛出异常,而不是简单的返回错误信息。通过捕获异常...

    PHP5中文手册+(生成时间2007-08-12+CHM格式)

    4. 类型提示:在函数或方法声明中,可以使用类型提示来指定参数类型,提高代码的健壮性。 5. 资源管理:PHP5提供了更好的资源管理,例如MySQLi数据库连接,比旧的MySQL扩展更安全、更高效。 6. SPL(标准PHP库):...

    PHP手册之整合最新评论CHM版

    CHM(Compiled Help Manual)是Microsoft的一种帮助文件格式,它将HTML文件、图像和其他资源打包成单一的离线查看文件,类似于电子书。这种格式的优点在于内容检索速度快,且占用磁盘空间小。PHP手册的CHM版意味着...

    PHP4 中文参考手册(CHM)

    - **数据库交互**:`mysql_connect`, `mysql_query`, `mysql_fetch_assoc` 等用于与 MySQL 数据库的交互。 **下载和源代码**: `mycodes.net` 文件可能是这个 CHM 手册的下载链接或包含手册的压缩文件名。CHM...

    PHP精华文摘(CHM).rar

    2. **PHP语法**:PHP的语法与其他C-like语言类似,但有其独特之处,比如在语句末尾使用分号,以及使用&lt;?php ... ?&gt;作为代码块的开始和结束标记。此外,PHP支持面向对象编程,包括类、对象、继承、封装和多态。 3. *...

    PHP5学习对象教程(CHM)

    CHM(Compiled Help Manual)格式是微软的一种帮助文档格式,它将文本、图像和索引等信息整合在一个文件中,方便读者查阅和学习。本教程通过深入浅出的方式,详细介绍了PHP5的基础知识、核心概念以及实际应用。 一...

    php手册中文版.rar

    你可以定义类,创建对象,使用构造函数和析构函数,实现抽象方法和接口,以及使用魔术方法来处理特定情况。 5. **错误和异常处理** PHP提供了错误报告机制,可以通过配置error_reporting和display_errors来控制。...

Global site tag (gtag.js) - Google Analytics