温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

MySQL5.6连接与断开mysql的详细方法

发布时间:2020-05-23 15:33:47 来源:网络 阅读:201 作者:三月 栏目:建站服务器

下面讲讲关于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的详细方法相关内容,大家还有什么不明白的地方吗?或者想要了解更多相关,可以继续关注我们的行业资讯板块。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI