MySQL5.6连接与断开mysql的详细方法
admin
2023-03-21 20:41:32
0

下面讲讲关于MySQL5.6连接与断开mysql的详细方法,文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完MySQL5.6连接与断开mysql的详细方法这篇文章你一定会有所受益。

3.1 Connecting to and Disconnecting from the Server

3.1连接和断开与云服务器的连接

To connect to the server, you will usually need to provide a MySQL user name when you invoke mysql and, most likely, a password. If the server runs on a machine other than the one where you log in, you will also need to specify a host name. Contact your administrator to find out what connection parameters you should use to connect (that is, what host, user name, and password to use). Once you know the proper parameters, you should be able to connect like this:

为了连接服务,你通常需要提供一个MySQL用户名,可能还需要密码。如果服务不在你所登陆的fu wu qish云服务器上运行,你还需要指定云服务器的主机名(或IP地址)。请与您的管理员联系,找出您应该使用哪些连接参数进行连接(即要使用的主机名,用户名和密码)。一旦你知道正确的参数,你应该可以这样连接:

shell> mysql -h host -u user -pEnter password: ********

host and user represent the host name where your MySQL server is running and the user name of your MySQL account. Substitute appropriate values for your setup. The ******** represents your password; enter it when mysql displays the Enter password: prompt.

If that works, you should see some introductory information followed by a mysql> prompt:

host和user 象征着MySQL云服务器的主机名和MySQL账户的用户名。为您的设置替换成适当的值。********代表你的密码; 当mysql显示Enter password:提示时输入。

如果配置正确,你应该看到一些介绍性信息,然后是一个mysql>提示:

shell> mysql -h host -u user -pEnter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 25338 to server version: 5.6.38-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql>

The mysql> prompt tells you that mysql is ready for you to enter SQL statements.

If you are logging in on the same machine that MySQL is running on, you can omit the host, and simply use the following:

mysql>提示 告诉你MySQL已经准备好让您输入SQL语句了。

假如MySQL运行的云服务器与你登陆的设备是同一台,你可以省略主机名设置,只需使用以下命令:

shell> mysql -u user -p

If, when you attempt to log in, you get an error message such as ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2), it means that the MySQL server daemon (Unix) or service (Windows) is not running. Consult the administrator or see the section of Chapter 2, Installing and Upgrading MySQL that is appropriate to your operating system.

For help with other problems often encountered when trying to log in, see Section B.5.2, “Common Errors When Using MySQL Programs”.

Some MySQL installations permit users to connect as the anonymous (unnamed) user to the server running on the local host. If this is the case on your machine, you should be able to connect to that server by invoking mysqlwithout any options:

如果您尝试登录时会收到错误消息(如 ERROR 2002(HY000)):无法通过套接字'/tmp/mysql.sock'(2)连接到本地MySQL云服务器,这意味着MySQL云服务器守护进程(Unix)或服务(Windows)未运行。请咨询管理员或参阅 第2章适用于您的操作系统的安装和升级MySQL部分。

有关尝试登录时经常遇到的其他问题的帮助,请参见第B.5.2节“使用MySQL程序时的常见错误”。

一些MySQL安装允许用户作为匿名(未命名)用户连接到在本地主机上运行的云服务器。如果您的机器是这种情况,您应该能够通过调用mysql连接到该云服务器,而不需要任何选项:

shell> mysql

After you have connected successfully, you can disconnect any time by typing QUIT (or \q) at the mysql> prompt:

连接成功后,您可以通过在提示符下键入QUIT(或\q)断开连接mysql>:

mysql> QUIT
Bye

On Unix, you can also disconnect by pressing Control+D.

Most examples in the following sections assume that you are connected to the server. They indicate this by themysql> prompt.

在Unix上,也可以通过按Control + D断开连接。

以下部分中的大多数示例假定您已连接到云服务器。他们通过mysql>提示来表示这一点 。

对于以上MySQL5.6连接与断开mysql的详细方法相关内容,大家还有什么不明白的地方吗?或者想要了解更多相关,可以继续关注我们的行业资讯板块。

相关内容

热门资讯

武大:极不认同OPPO母亲节广... 学校极不认同某手机厂商“母亲节”广告文案的内容表述和价值倾向。这与武汉大学立德树人的育人理念严重不符...
不法人员“刘佳”冒充下属企业投... 澎湃新闻记者 岳怀让5月7日,中国国新控股有限责任公司(简称“中国国新”)在官网发布了一则《关于不法...
“拖延军购只会使中国大陆获利”... 台立法机构5月8日表决通过蓝白版“军购特别条例”,预算上限由赖清德当局要求的1.25万亿新台币降至7...
经济热点快评丨前4个月进出口增... 王东辉据海关统计,今年前4月,我国货物贸易进出口总值16.23万亿元,同比增长14.9%,出口、进口...
陈高雅、马晓霖:欧洲议会的“傲... ▎2026年4月30日,欧洲议会在法国斯特拉斯堡举行全体会议。图源:欧洲议会多媒体中心作者 | 陈高...
国家体育总局:关注运动员赛场表... 国家体育总局有关部门负责人近日表示,近期,我们关注到全国多地出现通过商场大屏照片投放、线下粉丝聚集应...
华为坤灵代理商选型指南:重庆五... 导语:在数字化转型加速的当下,企业网络基础设施的稳定性与适配性直接影响业务效率。以华为坤灵系列产品为...
马里中部新一波极端武装袭击致数... 马里中部9日发生多起武装袭击,造成数十人死亡。一名消息人士表示,当地局势“令人担忧”。据悉,一个关联...
第四代自主超导量子计算机“本源... 来源:市场资讯 (来源:贝壳财经) 新京报贝壳财经讯(记者程子姣)5月9日,据本源量子官方公众号,本...