Today, on the MySQL test cluster, you encounter a problem with permissions:
Sqlexception:sql state:42000 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Access denied for user ' root ' @ '% ' to database ' Ranger ' errorcode:1044
I am logged in as root user MySQL, how to still encounter this problem, a bit fishy, I looked under the MySQL user table under the permissions information
Mysql> SELECT Host,user,password,grant_priv,super_priv from mysql.user;+--------------+---------+-------------- -----------------------------+------------+------------+| Host | User | Password nbsp;| Grant_priv | Super_priv |+--------------+---------+-------------------------------------------+------------+------------+| 192.168.28.% | Oozie | *fed29c14b2e900d70b11b1f1b370f953ba51a6a0 | N | Y | | 192.168.28.% | Hive | *fed29c14b2e900d70b11b1f1b370f953ba51a6a0 | N | Y | | 192.168.28.% | Root | *fed29c14b2e900d70b11b1f1b370f953ba51a6a0 | Y | Y | | localhost | Ranger | *84bb87f6bf7f61703b24ce1c9aa9c0e3f2286900 | N | N | | localhost | Root | 0 nbsp | Y | Y | | % | Root | *fed29c14b2e900d70b11b1f1b370f953ba51a6a0 | Y | Y | | 127.0.0.1 | Root | *fed29c14b2e900d70b11b1f1b370f953ba51a6a0 | Y | Y | | % | Ranger | *84bb87f6bf7f61703b24ce1c9aa9c0e3f2286900 | N | Y |+--------------+---------+-------------------------------------------+-------- ----+------------+
You can see that the authorization permission is not open: Grant_priv is set to N for [email protected]%. Repaired under
UPDATEMySQL.User SETGrant_priv=' Y ',Super_priv=' Y ' WHERE User=' Root ';FLUSH Privileges;
Log in again and it's OK. If you are unable to perform the update, stop the MySQL service first and then mysqld_safe--skip-grant-table & (This can refer to the previous article: http://blog.csdn.net/oDaiLiDong/article/details/50196661), And then start MySQL normally after you change it.
Solution Error code:1044. Access denied for user ' root ' @ '% ' to database