将 Java(Spring、Hibernate、MySql)项目从 Windows 迁移到 Debian
我正在Windows(IntelliJIdea)上编写项目,一切正常。它编译并运行。但是当我尝试在 Debian(GNU/Linux 5.0) 上运行时,出现
SEVERE:用户 'root'@'localhost' 访问被拒绝(使用密码:YES)
[java] 30.11.2010 15:39:04 org.hibernate.cfg.SettingsFactory buildSettings
[java] 警告:无法获取查询元数据的连接
[java] java.sql.SQLException:用户“root”@“localhost”访问被拒绝(使用密码:YES)
[java] 在 com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
[java] 在 com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
[java] 在 com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
我使用这样的 Spring 配置:
<bean id="mySqlDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/mydb"/>
<property name="username" value="mydb"/>
<property name="password" value="Fallout_3"/>
</bean>
<bean id="mySqlSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="mySqlDataSource"/>
<property name="mappingResources">
<list>
<value>entities/ClientPrices.hbm.xml</value>
<value>entities/User.hbm.xml</value>
<value>entities/Provider.hbm.xml</value>
<value>entities/MessageQueue.hbm.xml</value>
<value> hibernate/SimpleEntity.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create
hibernate.current_session_context_class=thread
</value>
</property>
</bean>
I am writing project on Windows (IntelliJIdea), and all OK. It compiles, and runs. But when I try to run on Debian(GNU/Linux 5.0), I have
SEVERE: Access denied for user 'root'@'localhost' (using password: YES)
[java] 30.11.2010 15:39:04 org.hibernate.cfg.SettingsFactory buildSettings
[java] WARNING: Could not obtain connection to query metadata
[java] java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
[java] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
I use such Spring config:
<bean id="mySqlDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/mydb"/>
<property name="username" value="mydb"/>
<property name="password" value="Fallout_3"/>
</bean>
<bean id="mySqlSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="mySqlDataSource"/>
<property name="mappingResources">
<list>
<value>entities/ClientPrices.hbm.xml</value>
<value>entities/User.hbm.xml</value>
<value>entities/Provider.hbm.xml</value>
<value>entities/MessageQueue.hbm.xml</value>
<value> hibernate/SimpleEntity.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create
hibernate.current_session_context_class=thread
</value>
</property>
</bean>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在 mysql 服务器中添加对 localhost 的 root 权限,
执行:
在 mysql 控制台上
You need to add permission to root for localhost in your mysql server
execute :
on your mysql console.