GRANT
The
GRANT
statement enables system administrators to create MySQL user accounts and to grant rights to accounts. To use GRANT
, you must have the GRANT
OPTION
privilege, and you must have the privileges that you are granting. The REVOKE
statement is related and enables administrators to remove account privileges. To determine what privileges an account has, use SHOW GRANTS
.GRANTpriv_type
[(column_list
)] [,priv_type
[(column_list
)]] ... ON [object_type
]priv_level
TOuser
[IDENTIFIED BY [PASSWORD] 'password
'] [,user
[IDENTIFIED BY [PASSWORD] 'password
']] ... [REQUIRE {NONE |ssl_option
[[AND]ssl_option
] ...}] [WITHwith_option
[with_option
] ...]object_type
: TABLE | FUNCTION | PROCEDUREpriv_level
: * | *.* |db_name
.* |db_name.tbl_name
|tbl_name
|db_name
.routine_name
with_option
: GRANT OPTION | MAX_QUERIES_PER_HOURcount
| MAX_UPDATES_PER_HOURcount
| MAX_CONNECTIONS_PER_HOURcount
| MAX_USER_CONNECTIONScount
ssl_option
: SSL | X509 | CIPHER 'cipher
' | ISSUER 'issuer
' | SUBJECT 'subject
'
REVOKE
SHOW VARIABLES
SHOW [GLOBAL | SESSION] VARIABLES [LIKE 'pattern
' | WHERE expr
]
SHOW VARIABLES
shows the values of MySQL system variables. This information also can be obtained using mysqladmin command. The LIKE
clause, if present, indicates which variable names to match. The WHERE
clause can be given to select rows using more general conditions. With the
GLOBAL
modifier, SHOW VARIABLES
displays the values that are used for new connections to MySQL. With SESSION
, it displays the values that are in effect for the current connection. If no modifier is present, the default is SESSION
. LOCAL
is a synonym for SESSION
.
SHOW STATUS provides server status information. The LIKE clause, if present, indicates which variable names to match SHOW [GLOBAL | SESSION] STATUS
[LIKE 'pattern
' | WHERE expr
]
With a LIKE
clause, the statement displays only rows for those variables with names that match the pattern: mysql> SHOW STATUS LIKE 'Key%';
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| Key_blocks_used | 14955 |
| Key_read_requests | 96854827 |
| Key_reads | 162040 |
| Key_write_requests | 7589728 |
| Key_writes | 3813196 |
+--------------------+----------+
SHOW SLAVE STATUS This statement provides status information on essential parameters of the slave threads. If you issue this statement using the `mysql` client, you can use a\G
statement terminator rather than a semicolon to obtain a more readable vertical layout: mysql>SHOW SLAVE STATUS\G
*************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: localhost Master_User: root Master_Port: 3306 Connect_Retry: 3 SHOW BINARY LOGS / SHOW MASTER LOGS Lists the binary log files on the server mysql>SHOW BINARY LOGS;
+---------------+-----------+ | Log_name | File_size | +---------------+-----------+ | binlog.000015 | 724935 | | binlog.000016 | 733481 | +---------------+-----------+ SHOW [STORAGE] ENGINES SHOW ENGINES displays status information about the server's storage engines. This is particularly useful for checking whether a storage engine is supported, or to see what the default engine is.SHOW TABLE TYPES
is a deprecated synonym. mysql>SHOW ENGINES\G
*************************** 1. row *************************** Engine: MyISAM Support: DEFAULT Comment: Default engine as of MySQL 3.23 with great performance *************************** 2. row *************************** Engine: MEMORY Support: YES Comment: Hash based, stored in memory, useful for temporary tables *************************** 3. row *************************** Engine: HEAP Support: YES Comment: Alias for MEMORY -- *************************** 4. row *************************** Engine: InnoDB Support: YES
SHOW ERRORS
SHOW ERRORS [LIMIT [offset
,]row_count
] SHOW COUNT(*) ERRORS
This statement is similar to SHOW WARNINGS
, except that instead of displaying errors, warnings, and notes, it displays only errors. SHOW WARNINGS
SHOW WARNINGS [LIMIT [offset
,] row_count
] SHOW COUNT(*) WARNINGS
show warnings shows the error, warning, and note messages that resulted from the last statement that generated messages in the current session. It shows nothing if the last statement used a table and generated no messages. (That is, a statement that uses a table but generates no messages clears the message list.) Statements that do not use tables and do not generate messages have no effect on the message list.
Warnings are generated for DML statements such as
INSERT
, UPDATE
, and LOAD DATA INFILE
as well as DDL statements such as CREATE TABLE
and ALTER TABLE
.
SHOW many forms that provide information about databases, tables, columns, or status information about the server. This section describes those following: SHOW CHARACTER SET [ALTER [IGNORE] TABLElike_or_where
] SHOW COLLATION [like_or_where
] SHOW [FULL] COLUMNS FROMtbl_name
[FROMdb_name
] [like_or_where
] SHOW CREATE DATABASEdb_name
SHOW CREATE FUNCTIONfunc_name
SHOW CREATE PROCEDUREproc_name
SHOW CREATE TABLEtbl_name
SHOW DATABASES [like_or_where
] SHOW ENGINEengine_name
{LOGS | STATUS } SHOW [STORAGE] ENGINES SHOW ERRORS [LIMIT [offset
,]row_count
] SHOW FUNCTION CODEfunc_name
SHOW FUNCTION STATUS [like_or_where
] SHOW GRANTS FORuser
SHOW INDEX FROMtbl_name
[FROMdb_name
] SHOW INNODB STATUS SHOW PROCEDURE CODEproc_name
SHOW PROCEDURE STATUS [like_or_where
] SHOW [BDB] LOGS SHOW MUTEX STATUS SHOW OPEN TABLES [FROMdb_name
] [like_or_where
] SHOW PRIVILEGES SHOW [FULL] PROCESSLIST SHOW PROFILE [types
] [FOR QUERYn
] [OFFSETn
] [LIMITn
] SHOW PROFILES SHOW [GLOBAL | SESSION] STATUS [like_or_where
] SHOW TABLE STATUS [FROMdb_name
] [like_or_where
] SHOW TABLES [FROMdb_name
] [like_or_where
] SHOW TRIGGERS [FROMdb_name
] [like_or_where
] SHOW [GLOBAL | SESSION] VARIABLES [like_or_where
] SHOW WARNINGS [LIMIT [offset
,]row_count
]like_or_where
: LIKE 'pattern
' | WHEREexpr
ALTER TABLE
tbl_name
alter_specification
[,alter_specification
] ...alter_specification
:table_options
| ADD [COLUMN]col_name
column_definition
[FIRST | AFTERcol_name
] | ADD [COLUMN] (col_name
column_definition
,...) | ADD {INDEX|KEY} [index_name
] [index_type
] (index_col_name
,...) [index_type
] | ADD [CONSTRAINT [symbol
]] PRIMARY KEY [index_type
] (index_col_name
,...) [index_type
] | ADD [CONSTRAINT [symbol
]] UNIQUE [INDEX|KEY] [index_name
] [index_type
] (index_col_name
,...) [index_type
] | ADD [FULLTEXT|SPATIAL] [INDEX|KEY] [index_name
] (index_col_name
,...) [index_type
] | ADD [CONSTRAINT [symbol
]] FOREIGN KEY [index_name
] (index_col_name
,...)reference_definition
| ALTER [COLUMN]col_name
{SET DEFAULTliteral
| DROP DEFAULT} | CHANGE [COLUMN]old_col_name
new_col_name
column_definition
[FIRST|AFTERcol_name
] | MODIFY [COLUMN]col_name
column_definition
[FIRST | AFTERcol_name
] | DROP [COLUMN]col_name
| DROP PRIMARY KEY | DROP {INDEX|KEY}index_name
| DROP FOREIGN KEYfk_symbol
| DISABLE KEYS | ENABLE KEYS | RENAME [TO]new_tbl_name
| ORDER BYcol_name
[,col_name
] ... | CONVERT TO CHARACTER SETcharset_name
[COLLATEcollation_name
] | [DEFAULT] CHARACTER SET [=]charset_name
[COLLATE [=]collation_name
] | DISCARD TABLESPACE | IMPORT TABLESPACEindex_col_name
:col_name
[(length
)] [ASC | DESC]index_type
: USING {BTREE | HASH | RTREE}table_options
:table_option
[[,]table_option
] ... To be continued...