2023-10-16 15:58:10,675 [JISQL] /usr/java/jdk8u372-b07/bin/java -cp /srv/gdp/3.0.0.0/defender/admin/db/mysql/mysql-connector-java.jar:/opt/gdp-srv/srv/gdp/3.0.0.0/defender/admin/jisql/lib/* org.apache.util.sql.Jisql -driver mysqlconj -cstring jdbc:mysql://10.209.34.101:3306/mysql -u root -p '***** **' -noheader -trim -c ; -query 'grant all privileges on db_ranger. to 'ranger'@'%' with grant option;' Loading class 'com.mysql.jdbc.Driver'. This is deprecated. The new driver class is 'com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. SQLException : SQL state: 42000 java.sql.SQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'db_ranger' ErrorCode: 1044 SQLException : SQL state: 42000 java.sql.SQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'db_ranger' ErrorCode: 1044 2023-10-16 15:58:12,078 [I] SQL statement execution failed!! retrying attempt 2 of total 3 Loading class 'com.mysql.jdbc.Driver'. This is deprecated. The new driver class is 'com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. SQLException : SQL state: 42000 java.sql.SQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'db_ranger' ErrorCode: 1044 SQLException : SQL state: 42000 java.sql.SQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'db_ranger' ErrorCode: 1044 2023-10-16 15:58:13,477 [I] SQL statement execution failed!! retrying attempt 3 of total 3 Loading class 'com.mysql.jdbc.Driver'. This is deprecated. The new driver class is 'com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. SQLException : SQL state: 42000 java.sql.SQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'db_ranger' ErrorCode: 1044 SQLException : SQL state: 42000 java.sql.SQLSyntaxErrorException: Access denied for user 'root'@'%' to database 'db_ranger' ErrorCode: 1044 2023-10-16 15:58:13,878 [E] Granting privileges to 'ranger' failed on 'db_ranger'

上述问题是由于用户'root'@'%'在数据库'db_ranger'上没有权限导致的。要解决此问题,您可以按照以下步骤进行操作:

  1. 确保您使用的是正确的用户名和密码。检查用户名和密码是否正确,并确保在密码前后没有额外的空格。

  2. 确保用户'root'@'%'具有在'db_ranger'数据库上授予权限的权限。您可以使用以下命令为用户'root'@'%'授予权限:

    GRANT ALL PRIVILEGES ON db_ranger.* TO 'root'@'%' WITH GRANT OPTION;
    

    请注意,此命令将授予用户'root'@'%'在'db_ranger'数据库上具有所有权限,并允许他们将权限授予其他用户。

  3. 如果您仍然遇到问题,可能是由于MySQL的权限配置问题导致的。请确认MySQL服务器的配置文件(通常是my.cnf或my.ini)中是否正确配置了权限和访问控制。您可以检查以下几个方面:

    • 确保配置文件中没有禁用'root'用户的访问。
    • 确保配置文件中允许远程访问,并允许用户'root'@'%'访问。
  4. 如果上述步骤都不起作用,您可以尝试使用具有更高权限的用户(例如MySQL的管理员用户)来授予'ranger'用户所需的权限。

请注意,为了安全起见,建议不要直接使用'root'用户进行操作。应该创建一个具有适当权限的新用户,并使用该用户进行数据库操作。

如果您仍然无法解决问题,请提供更多关于您的环境和配置的详细信息,以便我们能够提供更具体的帮助。

MySQL 权限错误:Access denied for user 'root'@'%' to database 'db_ranger' - 解决方法

原文地址: https://www.cveoy.top/t/topic/pjdP 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录