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. [P2698][USACO12MAR]花盆Flowerpot

    Link: P2698 传送门 Solution: 对于可行区间$[L,R]$,随着$L$的递增$R$不会递减 因此可以使用尺取法来解决此题:不断向右移动左右指针,复杂度保持线性 同时为了维护区间内的 ...

  2. 2017 Multi-University Training 2 解题报告

    Is Derek lying? Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  3. Activity(活动)生命周期--项目测试

    一.新建一个Activitylifetest项目,允许Android Studio帮我们自动创建活动和布局,并且勾选Luancher Activity来将创建的活动设置为主活动. 可以参考: http ...

  4. Problem C: 调用函数,求a+aa+aaa+....+aa...aa(n个a)

    #include <stdio.h> int fn(int a,int n)//定义函数 { ; ;i<=n;i++) { m=m+a;//当a=3时,m=3,然后a=30,m=33 ...

  5. [转]Spring MVC 4常用的那些注解

    Spring从2.5版本开始在编程中引入注解,用户可以使用@RequestMapping, @RequestParam, @ModelAttribute等等这样类似的注解.到目前为止,Spring的版 ...

  6. Codeforces Beta Round #3 B. Lorry 暴力 二分

    B. Lorry 题目连接: http://www.codeforces.com/contest/3/problem/B Description A group of tourists is goin ...

  7. war后缀的文件

    其实war文件就是Java中web应用程序的打包.借用一个老兄的话,"当你一个web应用程序很多的时候,如果你想把它部署到别的机器上,来回拷这些文件是件挺郁闷的事情,如果要是一个文件就好了. ...

  8. iOS:判断用户名是否以字母开头、手机号输入、邮箱是否正确的正则表达式

    新建一个字符串分类:NSString(Check),定义类方法更方便 .h文件 #import <Foundation/Foundation.h> @interface NSString ...

  9. [转载]《Delphi 版 everything、光速搜索代码》 关于获取文件全路径 GetFullFileName 函数的优化

    Delphi 版 everything.光速搜索代码>,文章中关于获取文件全路径的函数:GetFullFileName,有一个地方值得优化. 就是有多个文件,它们可能属于同一个目录. 譬如 Sy ...

  10. Java笔记20:迭代器模式

    迭代器模式 所谓Iterator模式,即是Iterator为不同的容器提供一个统一的访问方式.本文以Java中的容器为例,模拟Iterator的原理. 1 定义一个容器Collection接口 pub ...