MySQL操作笔记(1)

1.MySQL登录

--多实例登录方式,单实例不加-S参数;登录时尽量隐藏数据库密码。
[root@mysql ~]# mysql -S /data/3306/mysql.sock -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> quit
Bye

2.MySQL进程

--MySQL启动时进程mysqld和mysqld_safe
[root@mysql ~]# ps  -ef|grep mysql
root     11174     1  0 14:36 ?        00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --defaults-file=/data/3306/my.cnf
mysql    11992 11174  0 14:36 ?        00:00:00 /application/mysql-5.5.32/bin/mysqld --defaults-file=/data/3306/my.cnf --basedir=/application/mysql-5.5.32 --datadir=/data/3306/data --plugin-dir=/application/mysql-5.5.32/lib/plugin --user=mysql --log-error=/data/3306/mysql_3306.err --open-files-limit=8192 --pid-file=/data/3306/mysqld.pid --socket=/data/3306/mysql.sock --port=3306
root     12101 12066  0 15:21 pts/1    00:00:00 grep mysql

3.LINUX和MySQL操作命令记录

[root@mysql ~]# history -c
[root@mysql ~]# history -d 2
[root@mysql ~]# history 
    1  history
    2  history
    3  history -d 2
    4  history 
[root@mysql ~]# cd /root
[root@mysql ~]# ls -la
total 96
dr-xr-x---.  3 root root  4096 Nov  5 15:21 .
dr-xr-xr-x. 24 root root  4096 Nov  5 10:46 ..
-rw-------.  1 root root  2180 Nov  5 09:59 anaconda-ks.cfg
-rw-------.  1 root root  4676 Nov  5 15:17 .bash_history
-rw-r--r--.  1 root root    18 May 20  2009 .bash_logout
-rw-r--r--.  1 root root   176 May 20  2009 .bash_profile
-rw-r--r--.  1 root root   176 Sep 23  2004 .bashrc
-rw-r--r--.  1 root root  1053 Nov  5 10:20 .bzr.log
-rw-r--r--.  1 root root   100 Sep 23  2004 .cshrc
-rw-r--r--.  1 root root 28451 Nov  5 09:59 install.log
-rw-r--r--.  1 root root  7701 Nov  5 09:58 install.log.syslog
-rw-------.  1 root root  1092 Nov  5 15:21 .mysql_history
drwxr-xr-x.  3 root root  4096 Nov  5 10:20 .subversion
-rw-r--r--.  1 root root   129 Dec  4  2004 .tcshrc
-rw-------.  1 root root   630 Nov  5 14:58 .viminfo
[root@mysql ~]# cat .bash_history 
[root@mysql ~]# cat .mysql_history 
[root@mysql ~]# help history
history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
    Display or manipulate the history list.

    Display the history list with line numbers, prefixing each modified
    entry with a `*'.  An argument of N lists only the last N entries.

    Options:
      -c        clear the history list by deleting all of the entries
      -d offset delete the history entry at offset OFFSET.

      -a        append history lines from this session to the history file
      -n        read all history lines not already read from the history file
      -r        read the history file and append the contents to the history
        list
      -w        write the current history to the history file
        and append them to the history list

      -p        perform history expansion on each ARG and display the result
        without storing it in the history list
      -s        append the ARGs to the history list as a single entry

    If FILENAME is given, it is used as the history file.  Otherwise,
    if $HISTFILE has a value, that is used, else ~/.bash_history.

    If the $HISTTIMEFORMAT variable is set and not null, its value is used
    as a format string for strftime(3) to print the time stamp associated
    with each displayed history entry.  No time stamps are printed otherwise.

    Exit Status:
    Returns success unless an invalid option is given or an error occurs.

4.MySQL密码修改

[root@mysql ~]# mysql -u root -S /data/3306/mysql.sock  -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

--不退出执行linux命令,Oracle为host
mysql> system ls /data
3306  3307
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> show databases like 't%';
+---------------+
| Database (t%) |
+---------------+
| test          |
+---------------+
1 row in set (0.00 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

--(1)登录mysql方式修改,前提知道原密码,password函数
mysql> update user set password=password('123456') where user='system';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye


--(2)mysqladmin方式修改,前提知道原密码
[root@mysql ~]# mysqladmin -S /data/3306/mysql.sock  -u system -p111111  password '123456'
[root@mysql ~]# mysql -S /data/3306/mysql.sock  -u system -p123456


--(3)原密码丢失方式修改密码,忽略授权表
[root@mysql 3306]# /bin/sh /application/mysql/bin/mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables &
[root@mysql 3306]# mysql -S /data/3306/mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user,password from user;
+-----------+--------+-------------------------------------------+
| host      | user   | password                                  |
+-----------+--------+-------------------------------------------+
| localhost | root   | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
| mysql     | root   | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
| 127.0.0.1 | root   |                                           |
| localhost | system | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+--------+-------------------------------------------+
4 rows in set (0.00 sec)

mysql> update user set password=password('123456') where user='system';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select host,user,password from user;
+-----------+--------+-------------------------------------------+
| host      | user   | password                                  |
+-----------+--------+-------------------------------------------+
| localhost | root   | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
| mysql     | root   | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
| 127.0.0.1 | root   |                                           |
| localhost | system | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
+-----------+--------+-------------------------------------------+
4 rows in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

5.LINUX后台运行命令

[root@mysql 3306]# jobs
[1]+  Stopped                 /bin/sh /application/mysql/bin/mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables
[root@mysql 3306]# jobs -l
[1]+ 12640 Stopped                 /bin/sh /application/mysql/bin/mysqld_safe --defaults-file=/data/3306/my.cnf --skip-grant-tables
[root@mysql 3306]# kill -9 12640
[root@mysql 3306]# jobs -l

DQL DML DCL TPL命令


1.库操作

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> create database db;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| db                 |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql> show create database db \G;
*************************** 1. row ***************************
       Database: db
Create Database: CREATE DATABASE `db` /*!40100 DEFAULT CHARACTER SET latin1 */
1 row in set (0.00 sec)

ERROR: 
No query specified

mysql> Create Database: CREATE DATABASE db_gbk DEFAULT CHARACTER SET gbk;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ': CREATE DATABASE db_gbk DEFAULT CHARACTER SET gbk' at line 1
mysql> CREATE DATABASE db_gbk DEFAULT CHARACTER SET gbk;
Query OK, 1 row affected (0.00 sec)

mysql> CREATE DATABASE db_gbk DEFAULT CHARACTER SET utf8;
ERROR 1007 (HY000): Can't create database 'db_gbk'; database exists
mysql> CREATE DATABASE db_utf8 DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)

mysql> show databases like 'db%';
+----------------+
| Database (db%) |
+----------------+
| db             |
| db_gbk         |
| db_utf8        |
+----------------+
3 rows in set (0.00 sec)

mysql> drop database db;
Query OK, 0 rows affected (0.14 sec)


mysql> show databases like 'db%';
+----------------+
| Database (db%) |
+----------------+
| db_gbk         |
| db_utf8        |
+----------------+
2 rows in set (0.00 sec)

2.函数

mysql> use db_utf8;
Database changed
mysql> select version();
+------------+
| version()  |
+------------+
| 5.5.32-log |
+------------+
1 row in set (0.00 sec)

mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2015-11-05 17:05:41 |
+---------------------+
1 row in set (0.00 sec)

3.用户和权限

mysql> select host,user from mysql.user;
+-----------+--------+
| host      | user   |
+-----------+--------+
| 127.0.0.1 | root   |
| localhost | root   |
| localhost | system |
| mysql     | root   |
+-----------+--------+
4 rows in set (0.00 sec)

mysql> drop user system@localhost;
Query OK, 0 rows affected (0.00 sec)

--赋权及创建用户
mysql> grant all privileges on db_utf8.* to 'test'@'localhost' identified by 'test';
Query OK, 0 rows affected (0.00 sec)

mysql> show grants for test@localhost;
+---------------------------------------------------------------------------------------------------------------+
| Grants for test@localhost                                                                                   |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'test'@'localhost' IDENTIFIED BY PASSWORD '*43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A' |
| GRANT ALL PRIVILEGES ON `db_utf8`.* TO 'test'@'localhost'                                                   |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)


mysql> create user 'test123'@'localhost' identified by 'test';
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,password from mysql.user;
+-----------+-----------+-------------------------------------------+
| host      | user      | password                                  |
+-----------+-----------+-------------------------------------------+
| localhost | root      | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
| mysql     | root      | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
| 127.0.0.1 | root      |                                           |
| localhost | test      | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
| localhost | test123   | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
+-----------+-----------+-------------------------------------------+
5 rows in set (0.00 sec)

4.用户授权登录

--(110.0.0.%授权方式,方法可行
mysql> grant all privileges on db_utf8.* to 'test1'@'10.0.0.%' identified by 'test';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye

[root@mysql 3306]# mysql -u test1 -ptest -h 10.0.0.12 -S /data/3306/mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> quit
Bye
###################################################################################
--(2)10.0.0.0/24授权方式,方法不可行
mysql> grant all privileges on db_utf8.* to 'test2'@'10.0.0.0/24' identified by 'test';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@mysql 3306]# mysql -u test2 -ptest -h 10.0.0.12 -S /data/3306/mysql.sock 
ERROR 1045 (28000): Access denied for user 'test2'@'10.0.0.12' (using password: YES)

###################################################################################
--(310.0.0.0/255.255.255.0授权方式,方法可行
mysql> grant all privileges on db_utf8.* to 'test3'@'10.0.0.0/255.255.255.0' identified by 'test';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@mysql 3306]# mysql -u test3 -ptest -h 10.0.0.12 -S /data/3306/mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.32-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye

帮助
help show

mysql> help show
Name: 'SHOW'
Description:
SHOW has many forms that provide information about databases, tables,
columns, or status information about the server. This section describes
those following:

SHOW AUTHORS
SHOW {BINARY | MASTER} LOGS
SHOW BINLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]
SHOW CHARACTER SET [like_or_where]
SHOW COLLATION [like_or_where]
SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [like_or_where]
SHOW CONTRIBUTORS
SHOW CREATE DATABASE db_name
SHOW CREATE EVENT event_name
SHOW CREATE FUNCTION func_name
SHOW CREATE PROCEDURE proc_name
SHOW CREATE TABLE tbl_name
SHOW CREATE TRIGGER trigger_name
SHOW CREATE VIEW view_name
SHOW DATABASES [like_or_where]
SHOW ENGINE engine_name {STATUS | MUTEX}
SHOW [STORAGE] ENGINES
SHOW ERRORS [LIMIT [offset,] row_count]
SHOW EVENTS
SHOW FUNCTION CODE func_name
SHOW FUNCTION STATUS [like_or_where]
SHOW GRANTS FOR user
SHOW INDEX FROM tbl_name [FROM db_name]
SHOW MASTER STATUS
SHOW OPEN TABLES [FROM db_name] [like_or_where]
SHOW PLUGINS
SHOW PROCEDURE CODE proc_name
SHOW PROCEDURE STATUS [like_or_where]
SHOW PRIVILEGES
SHOW [FULL] PROCESSLIST
SHOW PROFILE [types] [FOR QUERY n] [OFFSET n] [LIMIT n]
SHOW PROFILES
SHOW SLAVE HOSTS
SHOW SLAVE STATUS
SHOW [GLOBAL | SESSION] STATUS [like_or_where]
SHOW TABLE STATUS [FROM db_name] [like_or_where]
SHOW [FULL] TABLES [FROM db_name] [like_or_where]
SHOW TRIGGERS [FROM db_name] [like_or_where]
SHOW [GLOBAL | SESSION] VARIABLES [like_or_where]
SHOW WARNINGS [LIMIT [offset,] row_count]

like_or_where:
    LIKE 'pattern'
  | WHERE expr

If the syntax for a given SHOW statement includes a LIKE 'pattern'
part, 'pattern' is a string that can contain the SQL "%" and "_"
wildcard characters. The pattern is useful for restricting statement
output to matching values.

Several SHOW statements also accept a WHERE clause that provides more
flexibility in specifying which rows to display. See
http://dev.mysql.com/doc/refman/5.5/en/extended-show.html.

URL: http://dev.mysql.com/doc/refman/5.5/en/show.html


mysql> grant all privileges on *.* to system@'localhost' identified by '123456' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,password from mysql.user;
+-----------+--------+-------------------------------------------+
| host      | user   | password                                  |
+-----------+--------+-------------------------------------------+
| localhost | root   | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
| mysql     | root   | *43FA3AFC0D22C2D3BB08ADEE0DCE2974611F603A |
| 127.0.0.1 | root   |                                           |
| localhost | system | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+--------+-------------------------------------------+
4 rows in set (0.00 sec)

[root@mysql bin]# mysqld_safe --help
Usage: /application/mysql/bin/mysqld_safe [OPTIONS]
  --no-defaults              Don't read the system defaults file
  --defaults-file=FILE       Use the specified defaults file
  --defaults-extra-file=FILE Also use defaults from the specified file
  --ledir=DIRECTORY          Look for mysqld in the specified directory
  --open-files-limit=LIMIT   Limit the number of open files
  --core-file-size=LIMIT     Limit core files to the specified size
  --timezone=TZ              Set the system timezone
  --malloc-lib=LIB           Preload shared library LIB if available
  --mysqld=FILE              Use the specified file as mysqld
  --mysqld-version=VERSION   Use "mysqld-VERSION" as mysqld
  --nice=NICE                Set the scheduling priority of mysqld
  --plugin-dir=DIR           Plugins are under DIR or DIR/VERSION, if
                             VERSION is given
  --skip-kill-mysqld         Don't try to kill stray mysqld processes
  --syslog                   Log messages to syslog with 'logger'
  --skip-syslog              Log messages to error log (default)
  --syslog-tag=TAG           Pass -t "mysqld-TAG" to 'logger'

All other options are passed to the mysqld program.

help grant

mysql> help grant
Name: 'GRANT'
Description:
Syntax:
GRANT
    priv_type [(column_list)]
      [, priv_type [(column_list)]] ...
    ON [object_type] priv_level
    TO user_specification [, user_specification] ...
    [REQUIRE {NONE | ssl_option [[AND] ssl_option] ...}]
    [WITH with_option ...]

GRANT PROXY ON user_specification
    TO user_specification [, user_specification] ...
    [WITH GRANT OPTION]

object_type:
    TABLE
  | FUNCTION
  | PROCEDURE

priv_level:
    *
  | *.*
  | db_name.*
  | db_name.tbl_name
  | tbl_name
  | db_name.routine_name

user_specification:
    user
    [
        IDENTIFIED BY [PASSWORD] 'password'
      | IDENTIFIED WITH auth_plugin [AS 'auth_string']
    ]

ssl_option:
    SSL
  | X509
  | CIPHER 'cipher'
  | ISSUER 'issuer'
  | SUBJECT 'subject'

with_option:
    GRANT OPTION
  | MAX_QUERIES_PER_HOUR count
  | MAX_UPDATES_PER_HOUR count
  | MAX_CONNECTIONS_PER_HOUR count
  | MAX_USER_CONNECTIONS count

The GRANT statement grants privileges to MySQL user accounts. GRANT
also serves to specify other account characteristics such as use of
secure connections and limits on access to server resources. To use
GRANT, you must have the GRANT OPTION privilege, and you must have the
privileges that you are granting.

Normally, a database administrator first uses CREATE USER to create an
account, then GRANT to define its privileges and characteristics. For
example:

CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
GRANT ALL ON db1.* TO 'jeffrey'@'localhost';
GRANT SELECT ON db2.invoice TO 'jeffrey'@'localhost';
GRANT USAGE ON *.* TO 'jeffrey'@'localhost' WITH MAX_QUERIES_PER_HOUR 90;

However, if an account named in a GRANT statement does not already
exist, GRANT may create it under the conditions described later in the
discussion of the NO_AUTO_CREATE_USER SQL mode.

The REVOKE statement is related to GRANT and enables administrators to
remove account privileges. See [HELP REVOKE].

When successfully executed from the mysql program, GRANT responds with
Query OK, 0 rows affected. To determine what privileges result from the
operation, use SHOW GRANTS. See [HELP SHOW GRANTS].

URL: http://dev.mysql.com/doc/refman/5.5/en/grant.html

help show grant

mysql> help show grants
Name: 'SHOW GRANTS'
Description:
Syntax:
SHOW GRANTS [FOR user]

This statement lists the GRANT statement or statements that must be
issued to duplicate the privileges that are granted to a MySQL user
account. The account is named using the same format as for the GRANT
statement; for example, 'jeffrey'@'localhost'. If you specify only the
user name part of the account name, a host name part of '%' is used.
For additional information about specifying account names, see [HELP
GRANT].

mysql> SHOW GRANTS FOR 'root'@'localhost';
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+

To list the privileges granted to the account that you are using to
connect to the server, you can use any of the following statements:

SHOW GRANTS;
SHOW GRANTS FOR CURRENT_USER;
SHOW GRANTS FOR CURRENT_USER();

If SHOW GRANTS FOR CURRENT_USER (or any of the equivalent syntaxes) is
used in DEFINER context, such as within a stored procedure that is
defined with SQL SECURITY DEFINER), the grants displayed are those of
the definer and not the invoker.

URL: http://dev.mysql.com/doc/refman/5.5/en/show-grants.html

mysql –help

[root@mysql 3306]# mysql --help
mysql  Ver 14.14 Distrib 5.5.32, for Linux (x86_64) using readline 5.1
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Usage: mysql [OPTIONS] [database]
  -?, --help          Display this help and exit.
  -I, --help          Synonym for -?
  --auto-rehash       Enable automatic rehashing. One doesn't need to use
                      'rehash' to get table and field completion, but startup
                      and reconnecting may take a longer time. Disable with
                      --disable-auto-rehash.
                      (Defaults to on; use --skip-auto-rehash to disable.)
  -A, --no-auto-rehash 
                      No automatic rehashing. One has to use 'rehash' to get
                      table and field completion. This gives a quicker start of
                      mysql and disables rehashing on reconnect.
  --auto-vertical-output 
                      Automatically switch to vertical output mode if the
                      result is wider than the terminal width.
  -B, --batch         Don't use history file. Disable interactive behavior.
                      (Enables --silent.)
  --character-sets-dir=name 
                      Directory for character set files.
  --column-type-info  Display column type information.
  -c, --comments      Preserve comments. Send comments to the server. The
                      default is --skip-comments (discard comments), enable
                      with --comments.
  -C, --compress      Use compression in server/client protocol.
  -#, --debug[=#]     This is a non-debug version. Catch this and exit.
  --debug-check       Check memory and open file usage at exit.
  -T, --debug-info    Print some debug info at exit.
  -D, --database=name Database to use.
  --default-character-set=name 
                      Set the default character set.
  --delimiter=name    Delimiter to be used.
  --enable-cleartext-plugin 
                      Enable/disable the clear text authentication plugin.
  -e, --execute=name  Execute command and quit. (Disables --force and history
                      file.)
  -E, --vertical      Print the output of a query (rows) vertically.
  -f, --force         Continue even if we get an SQL error.
  -G, --named-commands 
                      Enable named commands. Named commands mean this program's
                      internal commands; see mysql> help . When enabled, the
                      named commands can be used from any line of the query,
                      otherwise only from the first line, before an enter.
                      Disable with --disable-named-commands. This option is
                      disabled by default.
  -i, --ignore-spaces Ignore space after function names.
  --init-command=name SQL Command to execute when connecting to MySQL server.
                      Will automatically be re-executed when reconnecting.
  --local-infile      Enable/disable LOAD DATA LOCAL INFILE.
  -b, --no-beep       Turn off beep on error.
  -h, --host=name     Connect to host.
  -H, --html          Produce HTML output.
  -X, --xml           Produce XML output.
  --line-numbers      Write line numbers for errors.
                      (Defaults to on; use --skip-line-numbers to disable.)
  -L, --skip-line-numbers 
                      Don't write line number for errors.
  -n, --unbuffered    Flush buffer after each query.
  --column-names      Write column names in results.
                      (Defaults to on; use --skip-column-names to disable.)
  -N, --skip-column-names 
                      Don't write column names in results.
  --sigint-ignore     Ignore SIGINT (CTRL-C).
  -o, --one-database  Ignore statements except those that occur while the
                      default database is the one named at the command line.
  --pager[=name]      Pager to use to display results. If you don't supply an
                      option, the default pager is taken from your ENV variable
                      PAGER. Valid pagers are less, more, cat [> filename],
                      etc. See interactive help (\h) also. This option does not
                      work in batch mode. Disable with --disable-pager. This
                      option is disabled by default.
  -p, --password[=name] 
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty.
  -P, --port=#        Port number to use for connection or 0 for default to, in
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
                      /etc/services, built-in default (3306).
  --prompt=name       Set the mysql prompt to this value.
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
                      memory).
  -q, --quick         Don't cache result, print it row by row. This may slow
                      down the server if the output is suspended. Doesn't use
                      history file.
  -r, --raw           Write fields without conversion. Used with --batch.
  --reconnect         Reconnect if the connection is lost. Disable with
                      --disable-reconnect. This option is enabled by default.
                      (Defaults to on; use --skip-reconnect to disable.)
  -s, --silent        Be more silent. Print results with a tab as separator,
                      each row on new line.
  -S, --socket=name   The socket file to use for connection.
  -t, --table         Output in table format.
  --tee=name          Append everything into outfile. See interactive help (\h)
                      also. Does not work in batch mode. Disable with
                      --disable-tee. This option is disabled by default.
  -u, --user=name     User for login if not current user.
  -U, --safe-updates  Only allow UPDATE and DELETE that uses keys.
  -U, --i-am-a-dummy  Synonym for option --safe-updates, -U.
  -v, --verbose       Write more. (-v -v -v gives the table output format).
  -V, --version       Output version information and exit.
  -w, --wait          Wait and retry if connection is down.
  --connect-timeout=# Number of seconds before connection timeout.
  --max-allowed-packet=# 
                      The maximum packet length to send to or receive from
                      server.
  --net-buffer-length=# 
                      The buffer size for TCP/IP and socket communication.
  --select-limit=#    Automatic limit for SELECT when using --safe-updates.
  --max-join-size=#   Automatic limit for rows in a join when using
                      --safe-updates.
  --secure-auth       Refuse client connecting to server if it uses old
                      (pre-4.1.1) protocol.
  --server-arg=name   Send embedded server this as a parameter.
  --show-warnings     Show warnings after every statement.
  --plugin-dir=name   Directory for client-side plugins.
  --default-auth=name Default authentication client-side plugin to use.

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /application/mysql-5.5.32/etc/my.cnf ~/.my.cnf 
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
auto-rehash                       TRUE
auto-vertical-output              FALSE
character-sets-dir                (No default value)
column-type-info                  FALSE
comments                          FALSE
compress                          FALSE
debug-check                       FALSE
debug-info                        FALSE
database                          (No default value)
default-character-set             auto
delimiter                         ;
enable-cleartext-plugin           FALSE
vertical                          FALSE
force                             FALSE
named-commands                    FALSE
ignore-spaces                     FALSE
init-command                      (No default value)
local-infile                      FALSE
no-beep                           FALSE
host                              (No default value)
html                              FALSE
xml                               FALSE
line-numbers                      TRUE
unbuffered                        FALSE
column-names                      TRUE
sigint-ignore                     FALSE
port                              0
prompt                            mysql> 
quick                             FALSE
raw                               FALSE
reconnect                         TRUE
socket                            (No default value)
table                             FALSE
user                              (No default value)
safe-updates                      FALSE
i-am-a-dummy                      FALSE
connect-timeout                   0
max-allowed-packet                16777216
net-buffer-length                 16384
select-limit                      1000
max-join-size                     1000000
secure-auth                       FALSE
show-warnings                     FALSE
plugin-dir                        (No default value)
default-auth                      (No default value)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值