1)我安装了mysql;
2)我将bin-addres
行从127.0.0.1更改为我的服务器IP
3)我使用GRANT ALL ON *.* TO 'root'@'localhost';
更改了root权限,此行返回Query OK, 0 rows affected (0.00 sec)
4)我发起了SHOW GRANTS FOR 'root'@'localhost';
返回GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '******' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 1000
当我尝试使用hibernate连接到我的数据库时,系统会返回Access denied for user 'root'@'localhost' (using password: YES)
我该怎么办?
(Ps。我很抱歉英语不好)。
答案 0 :(得分:2)
允许从任何IP完全访问数据库或用您的IP替换%
从哪里访问数据库并尝试。
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES ;
答案 1 :(得分:0)
这是hibernate代码,错误是:
Access denied for user 'root'@'net-130-25-42-18.cust.vodafonedsl.it' (using password: YES)
我不知道为什么而不是localhost有' net-130-25-42-18.cust.vodafonedsl.it'
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://luxury:3306/newdb</property>
<property name="connection.username">root</property>
<property name="connection.password">Pass123</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<!-- Mapped classes -->
<mapping resource="applica/newdb/domain/model/User.hbm.xml" />
<mapping resource="applica/newdb/domain/model/Role.hbm.xml" />
</session-factory>
</hibernate-configuration>
答案 2 :(得分:0)
更改数据库连接URL
jdbc:mysql://your_database_server_domain_or_ip:3306/newdb
即
jdbc:mysql://example.com:3306/newdb