从 Clojure 连接到 mysql 服务器
我正在尝试从 clojure 连接到 mysql 数据库。我使用的示例代码取自: http://corfield.org/blog/post.cfm/connecting-clojure -and-mysql 但我收到此错误:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.
mysql 服务器绑定到 127.0.0.1:3306。将 :subname 中的 localhost 更改为 127.0.0.1 没有帮助。我已经将 mysql 服务器设置为记录所有内容以进行调试,但它甚至没有看到连接到来。我在这里做错了什么?
I'm trying to connect to a mysql database from clojure. I'm using the example code taken from:
http://corfield.org/blog/post.cfm/connecting-clojure-and-mysql but I'm getting this error:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.
The mysql server is bound to 127.0.0.1:3306. Changing localhost to 127.0.0.1 in :subname doesn't help. I have set the mysql server to log everything for debugging, and it doesn't even see a connection coming. What am I doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以使用 mysql -h 127.0.0.1 连接到数据库。但如果我将 127.0.0.1 更改为 localhost,则无法连接。 my.cnf 包含:
bind-address = 127.0.0.1
并且正如我上面所写,在 :subname 中更改为 127.0.0.1 没有帮助。解决这个问题的方法是将 mysqld : ALL : ALLOW 放入 /etc/hosts.allow 中。我不知道为什么需要这样做,特别是当所有其他联系 MySQL 服务器的服务都可以在没有它的情况下工作时。I can connect to the db using
mysql -h 127.0.0.1
. But this fails to connect if I change 127.0.0.1 to localhost. my.cnf contains:bind-address = 127.0.0.1
and as I write above, changing to 127.0.0.1 in :subname doesn't help. The thing that did the trick was puttingmysqld : ALL : ALLOW
in /etc/hosts.allow. I have no idea why this is needed, especially when all the other services that contact the MySQL server work without it.