MySQL 服务器报告启动正确,但在连接尝试时返回错误

发布于 2024-12-11 21:33:31 字数 1192 浏览 0 评论 0原文

我正在尝试设置我的本地开发环境,我正在使用非常容易安装的“WAMP”包。

现在我安装了wamp,运行它并启动所有服务,我尝试连接到MySQL服务器,但出现错误:

SQL Error (2003): Can't connect to MySQL server on 'localhost' (10060)

如果我通过SQL客户端或PHP尝试它并不重要,并且我已经尝试重新安装几次。

因此,我决定在启动后查看一下 mysql.log 文件,这就是我得到的结果:

111024 22:57:41 [Note] Plugin 'FEDERATED' is disabled.
111024 22:57:41 InnoDB: The InnoDB memory heap is disabled
111024 22:57:41 InnoDB: Mutexes and rw_locks use Windows interlocked functions
111024 22:57:41 InnoDB: Compressed tables use zlib 1.2.3
111024 22:57:41 InnoDB: Initializing buffer pool, size = 128.0M
111024 22:57:41 InnoDB: Completed initialization of buffer pool
111024 22:57:41 InnoDB: highest supported file format is Barracuda.
111024 22:57:41  InnoDB: Waiting for the background threads to start
111024 22:57:42 InnoDB: 1.1.8 started; log sequence number 1595675
111024 22:57:42 [Note] Event Scheduler: Loaded 0 events
111024 22:57:42 [Note] wampmysqld: ready for connections.
Version: '5.5.16-log'  socket: ''  port: 3306  MySQL Community Server (GPL)

倒数第二行显示“wampmysqld 已准备好连接”。表明它应该有效,这让我感到困惑......

我几乎不知道出了什么问题,所以我希望你们对我可以尝试做什么以使其启动并运行有任何建议。

I'm trying to set up my local development environment, to which i'm using the ever so easy to install "WAMP" package.

Now i install wamp, run it and start all services, i try connecting to the MySQL server, but i get an error:

SQL Error (2003): Can't connect to MySQL server on 'localhost' (10060)

It doesn't matter if i try it via a SQL client or PHP, and i've tried re-installing a few times.

So i decided to take a look at the mysql.log file after a startup, and this is what i get:

111024 22:57:41 [Note] Plugin 'FEDERATED' is disabled.
111024 22:57:41 InnoDB: The InnoDB memory heap is disabled
111024 22:57:41 InnoDB: Mutexes and rw_locks use Windows interlocked functions
111024 22:57:41 InnoDB: Compressed tables use zlib 1.2.3
111024 22:57:41 InnoDB: Initializing buffer pool, size = 128.0M
111024 22:57:41 InnoDB: Completed initialization of buffer pool
111024 22:57:41 InnoDB: highest supported file format is Barracuda.
111024 22:57:41  InnoDB: Waiting for the background threads to start
111024 22:57:42 InnoDB: 1.1.8 started; log sequence number 1595675
111024 22:57:42 [Note] Event Scheduler: Loaded 0 events
111024 22:57:42 [Note] wampmysqld: ready for connections.
Version: '5.5.16-log'  socket: ''  port: 3306  MySQL Community Server (GPL)

The second to last line reading "wampmysqld ready for connections." indicates it should work, which confuses me...

I have close to no idea what's wrong, so i hope you guys have any suggestions for what i can try to do in order to get this up and running.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

高速公鹿 2024-12-18 21:33:31

现在我已经被这个问题困扰了很长一段时间,但我相信我现在已经找到了解决方案。

我已经做了一切,从删除我能找到的所有包含“mysql”的文件到注册表数据库,但没有任何帮助。

我什至最终使用虚拟机作为临时解决方案,但当它更改 IP 时,我必须编辑 my.cnf,这是我实现我的 my.ini 的地方缺少 bind-address 值。

解决方案结果非常简单,尽管我不确定到底是做什么的。

无论如何,我最终在 my.ini 中编辑了一些内容,我编辑了这些行:

[client]
socket      = /tmp/mysql.sock

[wampmysqld]
socket      = /tmp/mysql.sock
log-bin=mysql-bin

我注释掉了 log-bin 行,编辑了 socket 行并添加了 bind-address 所以它看起来像这样:

[client]
socket      = C:/wamp/mysql.sock

[wampmysqld]
socket      = C:/wamp/mysql.sock
bind-address = 127.0.0.1

#log-bin=mysql-bin

正如我所说,不确定是做什么的,但是如果您由于某种原因遇到相同的问题,其中一些可能对您有用。

Now i have been troubled with this for quite some time, but i believe I've found a solution now.

I've done everything from deleting everything i could find containing "mysql" from files to the registry database, even so nothing helped.

I even ended up using a Virtual Machine as a temporary solution, but as it changed IP i had to edit the my.cnf, which is where i realized my my.ini missed the bind-address value.

The solution turned out to be annoyingly simple, even though i'm not sure exactly what did it.

Anyway, i ended up editing some things in the my.ini, i edited these rows:

[client]
socket      = /tmp/mysql.sock

[wampmysqld]
socket      = /tmp/mysql.sock
log-bin=mysql-bin

I commented out the log-bin line, edited the socket lines and added bind-address so it looked like this:

[client]
socket      = C:/wamp/mysql.sock

[wampmysqld]
socket      = C:/wamp/mysql.sock
bind-address = 127.0.0.1

#log-bin=mysql-bin

As i said, not sure what did it, but if you have the same problems for some reason, some of this might work for you.

请持续率性 2024-12-18 21:33:31

在 Windows 7 中,默认情况下“localhost”不会在本地解析。

假设(大假设!)您使用的是 Windows 7,您需要执行以下两件事之一:

  • 使用 mysql -h hostname -u root -p(使用您自己的主机名),以便它正确解析主机
  • ...或取消注释主机文件中包含 127.0.0.1 的行 (c:\windows\system32\drivers\etc\hosts)

第二个选项将允许默认主机“localhost ”当您在不指定主机名的情况下执行 mysql -u root -p 时使用。

In Windows 7, "localhost" doesn't resolve locally by default.

Assuming (big assumption!) you're using Windows 7, you'll need to do one of two things:

  • either use mysql -h hostname -u root -p (using your own hostname) so it resolves the host properly
  • ...or uncomment the line containing 127.0.0.1 in your hosts file (c:\windows\system32\drivers\etc\hosts)

The second option will allow the default host "localhost" to be used when you do mysql -u root -p without specifying a hostname.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文