当前位置: 技术问答>linux和unix
mysql访问权限问题,解答即放分,郁闷中
来源: 互联网 发布时间:2015-09-26
本文导语: 1.在mysql中创建用户并指定只能从本地连接数据库: mysql> grant select,insert,update,delete on caixin_match.* to test1@localhost identified by "test1"; 2.依然在这台机器上(本机)连接该数据库: java.sql.SQLException: Invalid authorization speci...
1.在mysql中创建用户并指定只能从本地连接数据库:
mysql> grant select,insert,update,delete on caixin_match.* to test1@localhost identified by "test1";
2.依然在这台机器上(本机)连接该数据库:
java.sql.SQLException: Invalid authorization specification: Access denied for user: 'test1@localhost.localdomain' (Using password: YES)
at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java:330)
at org.gjt.mm.mysql.Connection.connectionInit(Connection.java:261)
at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Connection.java:89)
at org.gjt.mm.mysql.Driver.connect(Driver.java:167)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at jdbc_connect.main(jdbc_connect.java:45)
Invalid authorization specification: Access denied for user: 'test1@localhost.localdomain' (Using password: YES)
为什么刚在mysql里创建的用户被程序说没权限呢,谢谢?
mysql> grant select,insert,update,delete on caixin_match.* to test1@localhost identified by "test1";
2.依然在这台机器上(本机)连接该数据库:
java.sql.SQLException: Invalid authorization specification: Access denied for user: 'test1@localhost.localdomain' (Using password: YES)
at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java:330)
at org.gjt.mm.mysql.Connection.connectionInit(Connection.java:261)
at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Connection.java:89)
at org.gjt.mm.mysql.Driver.connect(Driver.java:167)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at jdbc_connect.main(jdbc_connect.java:45)
Invalid authorization specification: Access denied for user: 'test1@localhost.localdomain' (Using password: YES)
为什么刚在mysql里创建的用户被程序说没权限呢,谢谢?
|
把mysql> grant select,insert,update,delete on caixin_match.* to test1@localhost identified by "test1";
改为
mysql> grant select,insert,update,delete on caixin_match.* to test1@localhost.localdomain identified by "test1";
在RH下,localhost.localdomain被视为localhost.Mysql里面也有说明.
改为
mysql> grant select,insert,update,delete on caixin_match.* to test1@localhost.localdomain identified by "test1";
在RH下,localhost.localdomain被视为localhost.Mysql里面也有说明.
|
再使用set password for test1@localhost=OLD_PASSWORD('test1');flush privileges;就可以正常链接了
|
是不是 test1@localhost 和 test1@localhost.localdomain 不一致造成的?
|
哪就加上引号限定一下,如:set password for 'test1'@'localhost' = OLD_PASSWORD('test1');这条语句时用于消除版本之间的差异的,应该没有问题的
|
mysql> grant select,insert,update,delete on caixin_match.* to test1@localhost identified by "test1";
这条语句只能让test1访问caixin_match这个数据库,看看连接mysql时有没有选择这个数据库
这条语句只能让test1访问caixin_match这个数据库,看看连接mysql时有没有选择这个数据库
|
你先试试本地命令行用此用户连接mysql行不行?
另外,我觉得你应该给他connect权限,grant connect to user
另外,我觉得你应该给他connect权限,grant connect to user