MySQL 无法建立连接,因为目标机器主动拒绝它(PHP / WAMP)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17707961/
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
No connection could be made because the target machine actively refused it (PHP / WAMP)
提问by Edward
Note: I realise this could be seen as a duplicate but i have looked at the other responses and they didn't fix the problem for me.
注意:我意识到这可能会被视为重复,但我已经查看了其他回复,他们没有为我解决问题。
I have recently installed Zend Studio and Zend Server with the mysql plugin on Windows 7.
我最近在 Windows 7 上使用 mysql 插件安装了 Zend Studio 和 Zend Server。
I am not a qualified server administrator but neither am i completely incompetent; i have dedicated my day trying to get a local development 'server' up to cut down on upload/download times.
我不是合格的服务器管理员,但也不是完全无能;我花了一天的时间试图建立一个本地开发“服务器”以减少上传/下载时间。
When I say server/machine i mean my home computer
当我说服务器/机器时,我指的是我的家用电脑
I have come to a grinding halt trying to get mysql to work with Zend Server.
我在尝试让 mysql 与 Zend Server 一起工作时陷入了停顿。
The error I keep receiving is (or verbose):
我不断收到的错误是(或详细):
#2002 Cannot log in to the MySQL server
or (if i change to 'config' authentication type)
#2002 - No connection could be made because the target machine actively refused it.
The server is not responding (or the local server's socket is not correctly configured).
I have tried:
我试过了:
- Change $cfg['Servers'][$i]['host'] from 'localhost' to '127.0.0.1'
- Add/Remove $cfg['Servers'][$i]['socket'] = '';
- Change from cookie to config auth type
- reinstall server and mysql
- Disable firewalls
- Restarting machine
- 将 $cfg['Servers'][$i]['host'] 从 'localhost' 更改为 '127.0.0.1'
- 添加/删除 $cfg['Servers'][$i]['socket'] = '';
- 从 cookie 更改为配置身份验证类型
- 重新安装服务器和mysql
- 禁用防火墙
- 重启机器
Zend's approach was to 'configure the phpmyadmin setup screen'... done that i don't know how many times.
Zend 的方法是“配置 phpmyadmin 设置屏幕”……我不知道做了多少次。
Can anyone on here lend a hand, or point me in a direction that I haven't tried yet?
这里的任何人都可以伸出援手,或者给我指出我还没有尝试过的方向吗?
回答by Wajdan Zahid
- Go to C:\wamp\bin\mysql\mysql[your-version]\data
- Copy and save "ib_logfile0" and "ib_logfile1" anywhere else.
- delete "ib_logfile0" and ib_logfile1
- 转到 C:\wamp\bin\mysql\mysql[your-version]\data
- 将“ib_logfile0”和“ib_logfile1”复制并保存在其他任何位置。
- 删除“ib_logfile0”和ib_logfile1
Did the trick for me. hope it works for you too.
对我有用。希望它也适用于你。
Its working fine. But we will have to stop apache and mysql, We need to quit xampp and then delete file. when deleted successfully. now start xampp it will work properly..
它的工作正常。但是我们将不得不停止apache和mysql,我们需要退出xampp然后删除文件。删除成功后。现在启动 xampp 它将正常工作..
回答by hashkishor
Just Go to your Control-panel and start Apache & MySQL Services.
只需转到您的控制面板并启动 Apache 和 MySQL 服务。
回答by T.Todua
You might need:
您可能需要:
In
wamp\bin\mysql\mysqlX.X.XX\my.ini
find these lines:[client] ... port = 3308 ... [wampmysqld64] ... port = 3308
在
wamp\bin\mysql\mysqlX.X.XX\my.ini
找到这些行:[client] ... port = 3308 ... [wampmysqld64] ... port = 3308
As you see, the port number is 3308
. You should :
如您所见,端口号是3308
。你应该 :
- use that port in applications, like WordPress:
define('DB_HOST', 'localhost:3308')
- 在应用程序中使用该端口,例如 WordPress:
define('DB_HOST', 'localhost:3308')
or
或者
- change it globally in
wamp\bin\apache\apache2.X.XXX\bin\php.ini
changemysqli.default_port = ...
to3308
- 将其全局
wamp\bin\apache\apache2.X.XXX\bin\php.ini
更改mysqli.default_port = ...
为3308
回答by spiderman
Till yesterday I was able to connect to phpMyAdmin, but today I started getting this error:
直到昨天我才能够连接到phpMyAdmin,但今天我开始收到此错误:
2002-no-connection-could-be-made-because-the-target-machine-actively-refused
2002-no-connection-could-be-made-because-the-target-machine-actively-refused
None of the answers here really helped me fix the problem, what helped me is shared below:
这里的答案都没有真正帮助我解决问题,下面分享了对我有帮助的内容:
I looked at the mysql logs.[C:\wamp\logs\mysql.log]
我查看了 mysql 日志。 [C:\wamp\logs\mysql.log]
It said
它说
2015-09-18 01:16:30 5920 [Note] Plugin 'FEDERATED' is disabled.
2015-09-18 01:16:30 5920 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-09-18 01:16:30 5920 [Note] InnoDB: The InnoDB memory heap is disabled
2015-09-18 01:16:30 5920 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2015-09-18 01:16:30 5920 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-09-18 01:16:30 5920 [Note] InnoDB: Not using CPU crc32 instructions
2015-09-18 01:16:30 5920 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-09-18 01:16:30 5920 [Note] InnoDB: Completed initialization of buffer pool
2015-09-18 01:16:30 5920 [Note] InnoDB: Highest supported file format is Barracuda.
2015-09-18 01:16:30 5920 [Note] InnoDB: The log sequence numbers 1765410 and 1765410 in ibdata files do not match the log sequence number 2058233 in the ib_logfiles!
2015-09-18 01:16:30 5920 [Note] InnoDB: Database was not shutdown normally!
2015-09-18 01:16:30 5920 [Note] InnoDB: Starting crash recovery.
2015-09-18 01:16:30 5920 [Note] InnoDB: Reading tablespace information from the .ibd files...
2015-09-18 01:16:30 5920 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace harley/login_confirm uses space ID: 6 at filepath: .\harley\login_confirm.ibd. Cannot open tablespace testdb/testtable which uses space ID: 6 at filepath: .\testdb\testtable.ibd
InnoDB: Error: could not open single-table tablespace file .\testdb\testtable.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
I got the clue that this guy is creating a problem - InnoDB: Error: could not open single-table tablespace file .\testdb\testtable.ibd
我得到了这个人在制造问题的线索—— InnoDB: Error: could not open single-table tablespace file .\testdb\testtable.ibd
and this line 2015-09-18 01:16:30 5920 [Note] InnoDB: Database was not shutdown normally!
和这条线 2015-09-18 01:16:30 5920 [Note] InnoDB: Database was not shutdown normally!
hmmm, For me the testdb was just a test-db! hence I decided to delete this file inside C:\wamp\bin\mysql\mysql5.6.17\data\testdb
嗯,对我来说,testdb 只是一个 test-db!因此我决定删除 C:\wamp\bin\mysql\mysql5.6.17\data\testdb 中的这个文件
and restarted all services, and went to phpMyAdmin, and this time no issues, phpMyAdmin opened :)
并重新启动所有服务,然后转到 phpMyAdmin,这次没有问题,phpMyAdmin 打开了 :)
回答by SRMR
I'm having the same problem with Wampserver. It's worked for me:
我在 Wampserver 上遇到了同样的问题。它对我有用:
You must change this file: "C:\wamp\bin\mysql[mysql_version]\my.ini" For example: "C:\wamp\bin\mysql[mysql5.6.12]\my.ini"
您必须更改此文件:“C:\wamp\bin\mysql[mysql_version]\my.ini” 例如:“C:\wamp\bin\mysql[mysql5.6.12]\my.ini”
And change default port 3306 to 80. (Lines 20 & 27, in both)
并将默认端口 3306 更改为 80。(第 20 行和第 27 行,两者中)
port = 3306 To port = 80
端口 = 3306 到端口 = 80
I hope this is helpful.
我希望这是有帮助的。
回答by paulalexandru
All I have to do in order to get rid of that error was to restart my wamp server.
为了摆脱该错误,我所要做的就是重新启动我的 wamp 服务器。
回答by Naz141
In my case i did the following and worked for me
就我而言,我做了以下工作并为我工作
- I clicked on the wamp icon.
- i went to MySQL > Service administration 'wampmysqld64' > install service
- Then click on wamp icon > Restart all service.
- 我点击了 wamp 图标。
- 我去了 MySQL > 服务管理 'wampmysqld64' > 安装服务
- 然后单击 wamp 图标 > 重新启动所有服务。
回答by Vinu
I have just removed the mysql service and installed it again. It works for me
我刚刚删除了mysql服务并重新安装了它。这个对我有用
回答by Rifan I
Please check your hosts file in etc folder and add below comments then run wamp server.
请检查 etc 文件夹中的主机文件并添加以下注释,然后运行 wamp 服务器。
127.0.0.1 localhost
127.0.0.1 本地主机
Path : C:\Windows\System32\drivers\etc
路径:C:\Windows\System32\drivers\etc
回答by Vipin Kumar R. Jaiswar
Kindly check is your mysql-service is running.
请检查您的 mysql-service 是否正在运行。
for windows user:check the services - mysql service
对于 Windows 用户:检查服务 - mysql 服务
for Linux user:Check the mysql service/demon is running (services mysql status)
对于 Linux 用户:检查 mysql 服务/恶魔是否正在运行(服务 mysql 状态)
Thanks & Regards Jaiswar Vipin Kumar R
感谢和问候 Jaiswar Vipin Kumar R