php 由于“拒绝连接”,我无法使用 MySQL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23012836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I am unable to use MySQL due to a "refused connection"
提问by cecilli0n
I am trying to run the no-install version of MySQL on Windows XP located in C:/mysql/on my machine.
我正在尝试在我的机器上位于C:/mysql/ 的Windows XP 上运行 MySQL 的免安装版本。
The error message I receive within a PHP file when I try to connect to MySQL reads.
当我尝试连接到 MySQL 时,我在 PHP 文件中收到的错误消息读取。
Could not connect: No connection could be made because the target machine actively refused it
无法连接:无法连接,因为目标机器主动拒绝它
I have edited the config file my.iniand altered/added the following.
我编辑了配置文件my.ini并更改/添加了以下内容。
[client]
port = 3306
socket = C:/mysql/tmp/mysql.sock
[mysqld]
port = 3306
socket = C:/mysql/tmp/mysql.sock
basedir = C:/mysql/
datadir = C:/mysql/data/
bind-address = 127.0.0.1
skip-networking
enable-named-pipe
When I run mysqld.exe I can confirm it is running within command prompt tasklist. However when I try cmd netstat -aI cannot see any port usage at 3306.
当我运行 mysqld.exe 时,我可以确认它正在命令提示符任务列表中运行。但是,当我尝试 cmd netstat -a 时,我在 3306 上看不到任何端口使用情况。
Inside MySQL error logs, it reads.
在 MySQL 错误日志中,它读取。
140411 13:30:34 [Note] c:\mysql\bin\mysqld.exe: ready for connections. Version: '5.5.37-log' socket: '' port: 0 MySQL Community Server (GPL)
140411 13:30:34 [注意] c:\mysql\bin\mysqld.exe:准备连接。版本:'5.5.37-log' 套接字:'' 端口:0 MySQL 社区服务器 (GPL)
The port: 0 doesn't look correct to me, but I am not sure.
端口:0 对我来说看起来不正确,但我不确定。
When I run mysql.exe direct in cmd I get the following returned
当我直接在 cmd 中运行 mysql.exe 时,我得到以下返回
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
Some things I have tried already.
有些事情我已经尝试过了。
- Placing a copy of my.iniin C:/WINDOWS and also a copy within C:/mysql
- Changing bind-address = 127.0.0.1to bind-address = localhost
- Inside PHP file MySQL connection variants, localhost, 127.0.0.1, 127.0.0.1:3306inside basic mysql_connect()
- Created tmp/mysql.sock file (in case dir + file not existing matters)
- Commented out skip-networkingin my.ini
- After running mysqld.exe whilst running ran mysqladmin.exe in cmd which returns 'Can't connect to MySQL server at 'localhost'
- Running telnet localhost 3306 returns 'Connecting To localhost...Could not open connection to the host, on port 3306: C onnect failed'
- Commented out bind-addressin my.inito allow default settings.
- Ran mysqld.exe with user root (-u root) also inserted user = rootin my.ini
- Set Windows Firewall to off.
- 在 C:/WINDOWS 中放置my.ini的副本,并在 C:/mysql 中放置一个副本
- 将绑定地址 = 127.0.0.1更改为绑定地址 = localhost
- PHP 文件内部 MySQL 连接变体,localhost,127.0.0.1,127.0.0.1:3306内部基本 mysql_connect()
- 创建 tmp/mysql.sock 文件(以防 dir + 文件不存在)
- 在my.ini 中注释掉跳过网络
- 在运行 mysqld.exe 的同时在 cmd 中运行 mysqladmin.exe 后,返回“无法连接到 'localhost' 处的 MySQL 服务器”
- 运行 telnet localhost 3306 返回“正在连接到 localhost...无法打开与主机的连接,在端口 3306 上:连接失败”
- 注释掉绑定地址在my.ini中允许默认设置。
- 冉mysqld.exe与用户根(-u根)也插入用户=根中的my.ini
- 将 Windows 防火墙设置为关闭。
Thanks in advance.
提前致谢。
采纳答案by Soyale
Ok. You have binded your server to specific ip so please read this MySQL bind-addres. Please unbind your server and check if you have proper user. (last paragraph in documentation)
好的。您已将您的服务器绑定到特定 ip,因此请阅读此MySQL bind-addres。请解绑您的服务器并检查您是否有合适的用户。(文档中的最后一段)