某SSH2项目在开发时正常,在Linux部署时报错:Could not open connection at

org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection at
……
用户名密码都没问题。

阅读 4.6k
1 个回答

其实我们往下看,还能看到这条关键信息:
java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=localhost)(port=3306)(type=master) : Connection refused (Connection refused) at

我们看到Connection refused,但是没有说明具体原因。经过我的查找排除,最终发现是XAMPP的Linux版的安全加固程序:
/opt/lampp/lampp security
运行之后,mariadb的my.cnf的skip-networking就起作用了,这样就只能通过UNIX Socket方式访问数据库了,不能使用TCP方式访问数据库,这会影响Java EE程序,导致Connection refused。把它注释掉再重启mariadb就好了。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进