如题,项目通过镜像迁移到另一个服务器后,开启项目,无法链接本机Mysql,但是用开发电脑通过外网IP链接是可以的
查看日志 抛出下面两个异常
Unable to set localhost. This prevents creation of a GUID. Cause was iZj6cemhzvwh37aspfpazgZ
2017-12-08 11:41:15 [ERROR] - com.alibaba.druid.pool.DruidDataSource -Log4j2Impl.java(53) -create connection error, url: jdbc:mysql://127.0.0.1:3306/xytour?useUnicode=true&characterEncoding=utf-8, errorCode 0, state 08S01com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
意思就是系统不知道"iZj6cemhzvwh37aspfpazgZ" 是什么东西、 无法链接mysql
想了一下这"iZj6cemhzvwh37aspfpazgZ" 很像阿里云的主机命名格式,看了一下果然是旧服务器的名字,然后想到外网能连mysql,本机不能连?肯定是host的问题。。
编辑 /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 {你的主机名}::1 localhost localhost.localdomain localhost6 localhost6.localdomain6{主机的内网IP} {你的主机名}
重启项目,搞定