Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用java jdbc驱动程序连接到Mysql_Java_Mysql_Linux_Hibernate_Tomcat - Fatal编程技术网

无法使用java jdbc驱动程序连接到Mysql

无法使用java jdbc驱动程序连接到Mysql,java,mysql,linux,hibernate,tomcat,Java,Mysql,Linux,Hibernate,Tomcat,我正在使用Spring数据和hibernate在Tomcat7中构建一个应用程序。我让它在我的mac上运行,但是当我将应用程序移植到我的linux服务器上,并更改配置以匹配MySQL登录时,我在Tomcat启动时遇到了连接异常 我的开发环境(工作环境)和生产环境(不工作环境)之间的一些差异: -开发是mac,生产是linux -开发MySQL版本:Ver 14.14 Distrib 5.6.16,用于使用编辑行包装的osx10.9(x86_64),生产MySQL版本:Ver 14.14 Dist

我正在使用Spring数据和hibernate在Tomcat7中构建一个应用程序。我让它在我的mac上运行,但是当我将应用程序移植到我的linux服务器上,并更改配置以匹配MySQL登录时,我在Tomcat启动时遇到了连接异常

我的开发环境(工作环境)和生产环境(不工作环境)之间的一些差异: -开发是mac,生产是linux -开发MySQL版本:Ver 14.14 Distrib 5.6.16,用于使用编辑行包装的osx10.9(x86_64),生产MySQL版本:Ver 14.14 Distrib 5.5.37,用于使用readline 6.2的debian linux gnu(x86_64)

hibernate.properties如下所示:

hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost:3306/<dbname>
hibernate.connection.username=root
hibernate.connection.password=<root password>
hibernate.dialogue=org.hibernate.dialogue.mysqldialogue
hibernate.connection.driver\u class=com.mysql.jdbc.driver
hibernate.connection.url=jdbc:mysql://localhost:3306/
hibernate.connection.username=root
hibernate.connection.password=

一件奇怪的事情是,在我的linux机器上,键入netstat命令时mysql没有显示,但我可以从命令行登录,没有问题。在mysql中,我输入了“ShowVariables”;端口返回为0。但是,当我将此端口放入hibernate属性时,Tomcat仍然无法连接。

您可以从mysql命令行创建数据库吗? 您确定mysqld正在正确运行吗?你说端口返回为0是什么意思


如何使用tomcat部署应用程序?您使用的是tomcat7 debian软件包还是其他软件包?消息异常确切地说是什么?

问题是MySQL没有正确运行。端口号为0,并且--skip networking处于打开状态。我重新启动了MySQL,下一次它正确启动了。在此之后,我可以成功连接。

我可以从mysql命令行创建数据库,我已经创建了它。我使用maven打包我的spring应用程序,命名为war ROOT.war,并将其放入$TOMCAT_HOME/webapps,然后运行$TOMCAT_HOME/webapps/bin/startup.sh。端口返回为0正是我所说的。在mysql命令行中,我键入“showvariables”;许多变量返回。端口变量显示为0。当我ps aux | grep mysql时,我得到以下结果:mysql 28881 0.0 1.1 615828 43844?Sl Jun02 3:34/usr/sbin/mysqld--跳过授权表--跳过网络