简体   繁体   中英

connection to mysql server from clojure

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?

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 putting mysqld : 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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