简体   繁体   English

从clojure连接到mysql服务器

[英]connection to mysql server from clojure

I'm trying to connect to a mysql database from clojure. 我正在尝试从clojure连接到mysql数据库。 I'm using the example code taken from: http://corfield.org/blog/post.cfm/connecting-clojure-and-mysql but I'm getting this error: 我使用的示例代码取自: 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.

The mysql server is bound to 127.0.0.1:3306. mysql服务器绑定到127.0.0.1:3306。 Changing localhost to 127.0.0.1 in :subname doesn't help. 在:subname中将localhost更改为127.0.0.1没有帮助。 I have set the mysql server to log everything for debugging, and it doesn't even see a connection coming. 我已将mysql服务器设置为记录所有调试信息,甚至看不到连接。 What am I doing wrong here? 我在这里做错了什么?

I can connect to the db using mysql -h 127.0.0.1 . 我可以使用mysql -h 127.0.0.1连接到数据库。 But this fails to connect if I change 127.0.0.1 to localhost. 但是,如果我将127.0.0.1更改为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. my.cnf包含: bind-address = 127.0.0.1 ,正如我在上面所写,在:subname中更改为127.0.0.1并没有帮助。 The thing that did the trick was putting mysqld : ALL : ALLOW in /etc/hosts.allow. 达到目的的是将mysqld : ALL : ALLOW放在/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. 我不知道为什么需要这样做,尤其是当与MySQL服务器联系的所有其他服务都没有它时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM