`
liujianguangaaa
  • 浏览: 231507 次
  • 性别: 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命令帮助(使用help或者help contents)

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

    本文主要给大家介绍了Mysql使用命令分级查找帮助的相关内容,本文章样例基于msql的分支版本MariaDB-10.1.19,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍: 查询所有帮助 我们如果希望知道...

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

    如何将MySQL help contents的内容有层次的输出呢?下面小编就为大家带来一篇将MySQL help contents的内容有层次的输出方法推荐。小编觉得挺不错的,现在分享给大家,给大家一个参考。一起跟随小编过来看看吧

    MySQL 5.6 Reference Manual

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

    mysql学习笔记之帮助文档

    mysql&gt; help contents; You asked for help about help category: "Contents" For more information, type 'help &lt;item&gt;', where &lt;item&gt; is one of the following categories: Account Management Administration ...

    VB编程资源大全(英文源码 数据库)

    The sample creates a new database file and allows you to view, add, or delete records in this database."&lt;END&gt;&lt;br&gt;2 , dbprint.zip&lt;br&gt;This demonstrates how to print data from a database.&lt;END&gt;&lt;br&gt;3 , ...

    R.for.Programmers.Mastering.the.Tools.14987368

    The contents are divided into four sections: The first section consists of the basics of R, which explains the advantages of using R, the installation of different versions of R, and the 12 ...

    Sql for mysql

    CHAPTER 1 Introduction to MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Database, ...

    Wrox.Professional.Website.Performance.2013

    Professional Website Performance: Optimizing the Front End and Back End offers essential information to help both front-end and back-end technicians ensure better website performance. From the Back ...

    WordPress 宝典.pdf

    它更能把握搜索引擎,在你使用 WordPress 并掌握几种插件后,对于优化将不用过多的操心,它会为你想的更多。  WordPress有许多第三方开发的免费模板,安装方式简单易用。不过要做一个自己的模板,则需要你有一定的...

    PHP经典教程 PHP 5 Fast & Easy Web Development

    Table of Contents PHP 5 Fast & Easy Web Development Introduction Part I - Getting Started Chapter 1 - Installing and Configuring MySQL Chapter 2 - Installing Apache Chapter 3 - Installing...

    Practical.Web.Development.1782175911

    Table of Contents Chapter 1: The World Wide Web Chapter 2: HTML Chapter 3: CSS Chapter 4: JavaScript Chapter 5: PHP Chapter 6: PHP and MySQL Chapter 7: jQuery Chapter 8: Ajax Chapter 9: The History ...

    Learning.PHP.7.1785880543

    Key Features ...This book is packed with real-life examples to help you implement the concepts as you learn Book Description ... ... You will set up ...

    Ajax Starter Kit

    Plug-n-play source code and popular Ajax framework libraries to help you reduce tedious typing and shorten programming tasks. Learn how to… Build better, more interactive interfaces for your web ...

    Advanced.Java.EE.Development.with.WildFly.1783288906

    A practical guide filled with easy-to-understand programming examples to help you gain hands-on experience with Java EE development using WildFly Who This Book Is For This book is for professional ...

    .Advanced.Java.EE.Development.with.WildFly.1783288906

    A practical guide filled with easy-to-understand programming examples to help you gain hands-on experience with Java EE development using WildFly Who This Book Is For This book is for professional ...

    Delphi7.1 Update

    =====================================================CONTENTS * INSTALLING THIS UPDATE * UPDATING LOCALIZED VERSIONS OF DELPHI 7 * KNOWN ISSUES * ISSUES ADDRESSED BY THIS UPDATE - IDE - CORE DATABASE...

    Joomla! 宝典.pdf

    是使用PHP语言加上MySQL数据库所开发的软件系统,可以在Linux、 Windows、MacOSX等各种不同的平台上执行。目前是由Open Source Matters (www.opensourcematters.org)这个开放源码组织进行开发与支持,这个组织的成员...

    Windows.10.for.the.Internet.of.Things.epub

    Chapter 13: Project 4: Using MySQL to Store Data Chapter 14: Project 5: Using a Web Server to Control Hardware Chapter 15: Project 6: Windows IoT and Arduino Chapter 16: Azure IoT Solutions: Cloud ...

    Geoserver Beginner`s Guide

    Chapter 12: Going Further: Getting Help and Troubleshooting 305 Going beyond maps 305 Delivering vector data 306 Time for action – retrieving vector data 306 Delivering raster data 310 Time for ...

Global site tag (gtag.js) - Google Analytics