mysql 数据库更改远程访问权限

上一篇 / 下一篇  2010-05-27 13:19:38 / 个人分类:Linux

最近在调试mysql数据库时,发生以下错误

 

18:04:45,575 ERROR [STDERR] org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select productlib0_.servicelibvalueid as servicel1_7_, productlib0_.productid as productid7_, productlib0_.servicelibtypeid as servicel3_7_, productlib0_.servicelibid as servicel4_7_ from conferencemanagement.productlibtype productlib0_ where (productlib0_.productid=? )]; SQL state [HY000]; error code [1449]; There is no 'root'@'%' registered; nested exception is java.sql.SQLException: There is no 'root'@'%' registered

18:04:45,577 ERROR [STDERR] Caused by:

18:04:45,577 ERROR [STDERR] java.sql.SQLException: There is no 'root'@'%' registered

18:04:45,578 ERROR [STDERR]         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)

18:04:45,578 ERROR [STDERR]         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)

18:04:45,578 ERROR [STDERR]         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)

18:04:45,578 ERROR [STDERR]         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)

18:04:45,578 ERROR [STDERR]         at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)

18:04:45,578 ERROR [STDERR]         at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)

18:04:45,578 ERROR [STDERR]         at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467)


排查错误,最后发现是数据库远程访问权限的问题,使用以下命令即可解决。

1. 登录mysql:mysql -uroot -ppasswd

2. 授权:GRANT ALL PRIVILEGES ON *.* TO'root'@'%'WITH GRANT OPTION //授权任何主机均有访问数据库的权限。

3. 重载权限信息:FLUSH PRIVILEGES //reload the grant tables

4. 退出:quit

另外,搜索到了其他修改方法,如下。

修改mysql数据库的user表

update user set host='%' where user = 'root';

select host, user from user;

有关mysql账户和权限管理的问题,可以参见以下文档

http://dev.mysql.com/doc/refman/5.0/en/adding-users.html


TAG: 权限 MySQL mysql

 

评分:0

我来说两句

我的栏目

日历

« 2024-03-27  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 13552
  • 日志数: 9
  • 建立时间: 2008-08-28
  • 更新时间: 2011-02-20

RSS订阅

Open Toolbar