MYSQL 连接数据库命令收藏-程序员宅基地

技术标签: mysql  

一、MySQL 连接本地数据库,用户名为“root”,密码“123”(注意:“-p”和“123” 之间不能有空格)
C:\>mysql -h localhost -u root -p123
二、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



分类: 数据库
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qing_2012/article/details/88327396

智能推荐

软件工程专业毕业设计 - 毕设选题推荐合集-程序员宅基地

文章浏览阅读1.3k次,点赞24次,收藏15次。软件工程专业毕业设计选题合集涵盖了管理系统、小程序、深度学习、机器学习、算法、人工智能、大数据、网络安全、嵌入式、推荐系统、目标检测等多个热门领域。对于计算机专业、软件工程专业、人工智能专业、通信工程专业的毕业生而言,选择一个合适的毕业设计选题至关重要。在这个毕业设计选题合集中,我们精心收集了各种有趣且具有挑战性的选题,旨在帮助学生们在毕业设计中展现他们的技术实力和创新能力。不论是对于对深度学习技术感兴趣的同学,还是希望探索机器学习、算法或人工智能的领域的同学,本合集都能为您提供丰富的选题资源和灵感。

Ac-PEG-AA不仅具有良好的反应活性,还具有良好的水溶性-程序员宅基地

文章浏览阅读309次,点赞3次,收藏4次。Ac-PEG-AA是由丙烯酸(AA)和聚乙二醇(PEG)通过酯化反应连接而成的。这种连接使得Ac-PEG-AA既具有PEG的特性,又具有丙烯酸的反应性。Ac-PEG-AA的乙酰基部分具有很好的反应性,能够与多种化学基团发生反应,从而实现与其他分子或材料的连接。丙烯酸部分则提供了可反应的羧基,可以与氨基、羟基等基团发生酯化或酰胺化反应,从而将Ac-PEG-AA与其他分子结合。规格标准:1g,5g,10g,可提供mg级以及kg级的产品开发服务。分子量:1k,2k,3.4k,5k,10k,20k(可按需定制)

HTML5 桌面通知:Notification API_html5 获取系统通知-程序员宅基地

文章浏览阅读630次。前言Notification API 是 HTML5 新增的桌面通知 API,用于向用户显示通知信息。该通知是脱离浏览器的,即使用户没有停留在当前标签页,甚至最小化了浏览器,该通知信息也一样会置顶显示出来。用户权限想要向用户显示通知消息,需要获取用户权限,而相同的域名只需要获取一次权限。只有用户允许的权限下,Notification 才能起到作用,避免某些网站的广告滥用 Notific_html5 获取系统通知

python求线性回归斜率-程序员宅基地

文章浏览阅读3.1k次。一、 先说我对这个题目的理解直线的x,y方程是这样的:y = kx+b, k就是斜率.求线性回归斜率, 就是说 有这么一组(x, y)的对应值——样本。如果有四组,就说样本量是4.根据这些样本,做“线性回归”,最终求出一条直线(即y = kx + b的k值和b值),使得样本里的各个点(x, y) “尽可能的”落到直线(或者直线附近)上。二、 python解题需要安装的包实际解题主要用到的pytho..._计算函数型线性回归模型的斜率

高泽龙:下一个独角兽来自长租公寓,行业创新极大地释放租赁红利_租赁前服务平台、租赁后服务平台、社区资产管理平台-程序员宅基地

文章浏览阅读1.2k次。超过万亿的巨大市场前景,九部委联合印发住房租赁新政,提出将采取多种措施加快推进租赁住房建设,培育和发展住房租赁市场,长租公寓尤其让众多资本机构觊觎,正在用惊人的扩张速度勾勒出一幅蓝图盛景。对于被称为“下一个风口”的公寓行业,各方有不同的解读,有的认为是互联网模式催生了房地产行业的变革,也有人认为这是个传统生意的升级变革,很难用互联网来改造和创新。无论如何,租赁公寓正在成为整个房地产行业、金融创投领_租赁前服务平台、租赁后服务平台、社区资产管理平台

常用的jdbc各种数据库的链接-程序员宅基地

文章浏览阅读494次。1、Oracle8/8i/9i数据库(thin模式) Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为数据库的SID String user="test";_常用的jdbc

随便推点

Linux防火墙管理_linux中的防火墙管理-程序员宅基地

文章浏览阅读1k次。接下来,我们演示关闭防火墙:(如果是非超级用户的操作,会要求我们输入当前系统用户的密码)Centos7下默认的防火墙是 Firewall。查看防火墙状态:(已经dead了!说明防火墙没有安装,需要安装。_linux中的防火墙管理

Unity Mesh实现图片切割(一)- 线与顶点_unity图形切片polygon-程序员宅基地

文章浏览阅读1.9k次。Unity Mesh实现图片切割(一)一、 PolygonCollider2D获取顶点和线段PolygonCollider2D中有points属性,对应和图形的顶点,PolygonCollider2D的顶点可以手动添加或者删除,右键Element X可选择删除这个点。由于Unity中所有图片都是连个三角面组成的矩形,在此需要手动拖动点勾勒出图片的有效切割范围。points属性的点顺序如图逆..._unity图形切片polygon

net_adm:names() 能得到所有的节点名-程序员宅基地

文章浏览阅读120次。Simon 10:07:42 有个命令,能得到所有的节点名,是什么? Android郎哲10:08:06 nodes() 熊心飞扬 10:08:09 nodes() Simon 10:08:35 不是,是得到本机器的所有节点名 Simon 10:08:43 什么names Android郎哲10:09:12 是得到本机器的所有节点名? Si..._:net_adm.names

如何利用空号检测 API 降低企业的业务成本_判断电话号码是否为空 api-程序员宅基地

文章浏览阅读364次。空号检测 API 是一种基于云计算的人工智能技术,它可以通过大数据算法、机器学习等技术对电话号码进行分析和处理,识别出有效和无效号码。_判断电话号码是否为空 api

《大话数据结构》前言-程序员宅基地

文章浏览阅读149次。前 言本书起因 大家好!我是《大话设计模式》(2008年初出版)的作者,三年来,承蒙广大读者的厚爱,《大话设计模式》取得了较大的成功。仅在当当网,截止本文写作时,就已经有1073次评论,705次5星评价,位居五星图书榜计算机/网络类的累计总榜第二名。此书已经成为国内原创计算机类图书最畅销的书籍之一。 对于这样一个自己喜欢做、可以做得好,而且已经得到了市场广泛认可,为..._复旦大学程晟涵

Intel- 64 与 IA-32架构软件开发人员手册 中文版_intel-64与ia-32架构软件开发人员手册中文版-程序员宅基地

文章浏览阅读5.7k次。1.2卷一总览:基本架构以下是本手册内容的描述:第一章——关于本手册.提供一个Intel- 64 与 IA-32架构软件开发人员手册五卷的概述,也描述了在该手册中使用的符号及其含义,列出了相关的因特尔手册和程序员文档以及硬件设计文档。第二章——Intel 64和IA-32架构.介绍了Intel- 64 与 IA-32架构以及基于这些架构的处理器家族,也给出了一个关于这些处理器共同特_intel-64与ia-32架构软件开发人员手册中文版