断电后,Tomcat无法与MySql通信

我错过了我的服务器付款,嘿,暂停我的帐户一天左右。 当他们把服务器备份起来时,我的所有数据都已经完成了,但由于某种原因,Tomcat无法与我的MySql服务器build立JDBC连接。 他们都运行在同一台机器上,因此我有一个127.0.0.1的绑定地址。

这很奇怪,因为我在没有问题之前自己重新设置了机器,但显然在停机时间里有些事情已经被重置了。

我遵循这个指南 (只是不涉及S3的位,我不在Amazon基础设施上),一切正常。

我是一个新的系统pipe理员,我不知道该怎么尝试,你会怎么去诊断这个问题? 我得到的堆栈跟踪如下;

INFO: Deploying web application archive myapp-1.1.war 2010-05-26 22:07:22,221 [main] ERROR context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:129) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:714) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:404) at org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext.refresh(GrailsWebApplicationContext.java:153) 

我得到了一些“豆”的错误。

如果我在我的命令提示符下键入mysql,那么我可以使用与使用GORM和Hibernate将对象保存到数据库的grails应用程序相同的凭据轻松login。

我可能没有提供足够的信息开始,但我真的很有兴趣学习,一定会提供它,如果问,我真的不知道从哪一个开始。

更新 :我可以通过在命令行运行二进制连接到MySQL。 我也通过tcp运行mysql,无法连接,这是否在这个问题上传播?

 root@88:~# mysql -u grails --protocol=tcp -p Enter password: ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (110) 

我有前面讨论过的绑定地址127.0.0.1所以也许这不是一个惊喜,这是行不通的。 有什么我需要检查我的主机文件?

谢谢,

GAV

使用mysql命令行工具和使用MySQL JDBC驱动程序的主要区别在于, mysql命令默认使用Unix套接字文件(例如/tmp/mysql.sock ),而JDBC驱动程序始终使用TCP / IP。

尝试强制使用mysql命令来使用TCP / IP,通过传递--protocol=tcp选项,看看会发生什么。 这可能会给你一个更明亮的错误信息(或者,如果成功,这也会告诉我们一些东西)。

首先要确保MySQL服务器正常运行:

 sudo /etc/init.d/mysqld status 

如果不是,请启动它:

 sudo /etc/init.d/mysqld start