http://hi.baidu.com/aaxh/blog/item/49bcb78ffe3dfae4f01f36b2.html一、MySQL 连接本地数据库,用户名为“root”,密码“123”(注意:“-p”和“123” 之间不能有空格)

C:\>mysql -h localhost -u root -p123(注意-p与密码是紧跟的)

二、MySQL 连接远程数据库(192.168.0.201),端口“3306”,用户名为“root”,密码“123”

C:\>mysql -h 172.16.16.45 -P 3306 -u root -p123

三、MySQL 连接本地数据库,用户名为“root”,隐藏密码

C:\>mysql -h localhost -u root -p

Enter password:

四、MySQL 连接本地数据库,用户名为“root”,指定所连接的数据库为“test”

C:\>mysql -h localhost -u root -p123 -D test

mysql>select database();

+------------+

| database() |

+------------+

| test       |

+------------+

下面是 MySQL 客户端命令的详细参数:

mysql  Ver 14.12 Distrib 5.0.41, for Win32 (ia32)

Copyright (C) 2002 MySQL AB

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL license

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.

-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. WARNING:

options deprecated; use --disable-auto-rehash instead.

-B, --batch         Don't use history file. Disable interactive behavior.

(Enables --silent)

--character-sets-dir=name

Directory where character sets are.

--default-character-set=name

Set the default character set.

-C, --compress      Use compression in server/client protocol.

-#, --debug[=#]     This is a non-debug version. Catch this and exit

-D, --database=name Database to use.

--delimiter=name    Delimiter to be used.

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

-g, --no-named-commands

Named commands are disabled. Use \* form only, or use

named commands only in the beginning of a line ending

with a semicolon (;) Since version 10.9 the client now

starts with this option ENABLED by default! Disable with

'-G'. Long format commands still work from the first

line. WARNING: option deprecated; use

--disable-named-commands instead.

-i, --ignore-spaces Ignore space after function names.

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

-L, --skip-line-numbers

Don't write line number for errors. WARNING: -L is

deprecated, use long version of this option instead.

-n, --unbuffered    Flush buffer after each query.

--column-names      Write column names in results.

-N, --skip-column-names

Don't write column names in results. WARNING: -N is

deprecated, use long version of this options instead.

-O, --set-variable=name

Change the value of a variable. Please note that this

option is deprecated; you can set variables directly with

--variable-name=value.

--sigint-ignore     Ignore SIGINT (CTRL-C)

-o, --one-database  Only update the default database. This is useful for

skipping updates to other database in the update log.

-p, --password[=name]

Password to use when connecting to server. If password is

not given it's asked from the tty.

-W, --pipe          Use named pipes to connect to server.

-P, --port=#        Port number to use for connection.

--prompt=name       Set the mysql prompt to this value.

--protocol=name     The protocol of 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.

-s, --silent        Be more silent. Print results with a tab as separator,

each row on new line.

--shared-memory-base-name=name

Base name of shared memory.

-S, --socket=name   Socket file to use for connection.

--ssl               Enable SSL for connection (automatically enabled with

other flags). Disable with --skip-ssl.

--ssl-ca=name       CA file in PEM format (check OpenSSL docs, implies

--ssl).

--ssl-capath=name   CA directory (check OpenSSL docs, implies --ssl).

--ssl-cert=name     X509 cert in PEM format (implies --ssl).

--ssl-cipher=name   SSL cipher to use (implies --ssl).

--ssl-key=name      X509 key in PEM format (implies --ssl).

--ssl-verify-server-cert

Verify server's "Common Name" in its cert against

hostname used when connecting. This option is disabled by

default.

-t, --table         Output in table format.

-T, --debug-info    Print some debug info at exit.

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

--no-tee            Disable outfile. See interactive help (\h) also. WARNING:

option deprecated; use --disable-tee instead

-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=#

Max packet length to send to, or receive from server

--net_buffer_length=#

Buffer 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

--show-warnings     Show warnings after every statement.

Default options are read from the following files in the given order:

C:\my.ini C:\my.cnf C:\WINDOWS\my.ini C:\WINDOWS\my.cnf D:\MySQL\my.ini D:\MySQL\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  Do not read default options from any options 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

character-sets-dir                (No default value)

default-character-set             utf8

compress                          FALSE

database                          (No default value)

delimiter                         ;

vertical                          FALSE

force                             FALSE

named-commands                    FALSE

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                              3306

prompt                            mysql>

quick                             FALSE

raw                               FALSE

reconnect                         TRUE

shared-memory-base-name           (No default value)

socket                            (No default value)

ssl                               FALSE

ssl-ca                            (No default value)

ssl-capath                        (No default value)

ssl-cert                          (No default value)

ssl-cipher                        (No default value)

ssl-key                           (No default value)

ssl-verify-server-cert            FALSE

table                             FALSE

debug-info                        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

linux 下远程连接mysql命令详解的更多相关文章

  1. Linux下的压缩解压缩命令详解

    linux zip命令zip -r myfile.zip ./*将当前目录下的所有文件和文件夹全部压缩成myfile.zip文件,-r表示递归压缩子目录下所有文件. 2.unzipunzip -o - ...

  2. Linux下的压缩解压缩命令详解及实例

    实例:压缩服务器上当前目录的内容为xxx.zip文件 zip -r xxx.zip ./* 解压zip文件到当前目录 unzip filename.zip ====================== ...

  3. linux下last与lastb命令详解

    在linux系统中,last与lastb命令用来列出目前与过去登录系统的用户相关信息.指令英文原义: last, lastb - show listing of last logged in user ...

  4. Linux下远程连接MySQL数据库

    估计搞了一个多小时才把这个远程连接搞好.一台本地电脑,一台云服务器,都是linux系统. 步骤 在服务器端开启远程访问 首先进入mysql数据库,然后输入下面两个命令: grant all privi ...

  5. Linux下tar压缩解压缩命令详解

    tar -c: 建立压缩档案-x:解压-t:查看内容-r:向压缩归档文件末尾追加文件-u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个.下面的 ...

  6. Linux下的tr编辑器命令详解

    通过使用 tr,您可以非常容易地实现 sed 的许多最基本功能.您可以将 tr 看作为 sed 的(极其)简化的变体:它可以用一个字符来替换另一个字符,或者可以完全除去一些字符.您也可以用它来除去重复 ...

  7. linux下find和grep命令详解

    在linux下面工作,有些命令能够大大提高效率.本文就向大家介绍find.grep命令,他哥俩可以算是必会的linux命令,我几乎每天都要用到他们.本文结构如下: find命令 find命令的一般形式 ...

  8. Linux下的scp拷贝命令详解

    相同Linux系统中对文件复制拷贝可以用CP命令: cp [options] source dest cp [options] source... directory 说明:将一个档案拷贝至另一档案, ...

  9. Linux下的grep搜索命令详解(一)

    Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达 ...

随机推荐

  1. BZOJ 2733 [HNOI2012]永无乡(启发式合并+Treap+并查集)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2733 [题目大意] 给出n个点,每个点都有自己的重要度,现在有连边操作和查询操作, 查 ...

  2. [UOJ218]火车管理

    建一棵答案线段树存栈顶值,两棵可持久化线段树分别存栈顶值和栈顶元素入栈时间 询问就直接在答案线段树上查,弹栈就用入栈时间在对应版本的可持久化线段树上查询即可,修改就是可持久化线段树的区间覆盖 以前一直 ...

  3. [xsy2123]毛毛虫

    题意:有一棵带点权的树,链修改是把$(x,y)$这条链和与其相邻的节点都加上一个数,查询是问$(x,y)$这条链和与其相邻的节点的权值和 学到了一个新姿势? 考虑树链剖分,在剖重链时每次给当前节点的儿 ...

  4. Perl读写文件&字符串操作

    Perl中读写文件的方法非常简单,可以使用open或sysopen函数来打开文件,linux下运行perl脚本只需 ./XX.pl 或 perl XX.pl. 读文件 open(文件句柄, " ...

  5. 连接mysql时1045错误的解决办法

    重装系统后,今天mysql提示1045错误无法连接上,找了很久得出方法如下: 修改root密码即可正常. 1,进入mysql控制台选择: 2,use mysql; 3,update user set ...

  6. FIS常用功能之MD5版本

    静态资源后缀加上md5参数,有效解决缓存更新问题 fis release --optimize --md5 使用前后对比:

  7. GitHub 上100个最受欢迎的Java基础类库

    作为一名整天与既成熟且不断发展的Java语言打交道的开发者,面对的困境之一就是在我们编写代码的时候,是使用一些人人谈论的人们新技术呢,还是坚持使用一些虽旧但成熟的类库? 由于Java应用中大部分是商业 ...

  8. Python结合Shell/Hadoop实现MapReduce

    基本流程为: cat data | map | sort | reduce cat devProbe | ./mapper.py | sort| ./reducer.py echo "foo ...

  9. 16.同步类容器Collections.synchronized

    voctor动态数组.同步类容器,底层实现基于:Collections.synchronized package demo5; import java.util.ArrayList; import j ...

  10. Neural Networks for Machine Learning by Geoffrey Hinton (4)

    一种能够学习家谱关系的简单神经网络 血缘一共同拥有12种关系: son, daughter, nephew, niece, father, mother, uncle, aunt, brother, ...