![](/img/trans.png)
[英]Not able to connect to mysql database using command line in windows 8
[英]MySql Running on Windows but Cannot Connect Using Command line
我在Windows Server 2008上使用MySql 5.6(64位,无需安装),服务运行良好,MySql Workbench可以成功连接。 但是,当尝试从本地主机使用命令提示符进行连接时,出现以下错误:
e:\\ mysql \\ bin> mysql -uroot -p输入密码:***********
错误2003(HY000):无法连接到“本地主机”上的MySQL服务器(10061)
有人可以帮忙吗?
打开服务( Start->Run-> "services.msc"
),然后检查MySQL是否正在运行。 如果不是,请运行它。
如果它已经在运行,则很可能是您的防火墙阻止了与端口3306(或您决定在其中运行MySQL的任何端口)的连接,然后您需要允许该端口的传入连接(允许连接取决于您使用的软件)重新使用)。
只是自己想出了问题。
MySql只能监听Windows Server的固定IP(例如10.33.40.26)。 在Windows“主机”文件中为该IP添加本地主机别名即可解决该问题。
10.33.40.26本地主机
主机文件的位置在Windows的不同版本上可能有所不同; 修改后,文件的最终外观如下:
C:\>more c:\windows\system32\drivers\etc\hosts
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
10.33.40.26 localhost
# ::1 localhost
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.