gpt4 book ai didi

MySQL - 授予访问权限不起作用

转载 作者:可可西里 更新时间:2023-11-01 08:45:55 24 4
gpt4 key购买 nike

我正在尝试授予用户对 mysql 中特定数据库的访问权限。但是命令好像没有生效。

我的意思是:

第一步:

  • 创建数据库'testdb'
  • 在 testbd 上授予 'dummyuser'@'%' 权限。*
  • 尝试使用 testdb 用户访问 mysql(失败)

root@bnode1/]# mysql -h 172.22.191.202 -u root -ppassword

MariaDB [(none)]> 
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS testdb;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on testdb.* to 'dummyuser'@'%' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@bnode1 /]#
[root@bnode1 /]# mysql -h 172.22.191.202 -u dummyuser -ppassword
ERROR 1045 (28000): Access denied for user 'dummyuser'@'bnode1' (using password: YES)

在 mysql 数据库上,我可以看到 dummyuser 的授予权限如下:

MariaDB [(none)]> show grants for 'dummyuser';
+-----------------------------------------+
| Grants for dummyuser@% |
+-----------------------------------------+
| GRANT USAGE ON *.* TO 'dummyuser'@'%' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' |
| GRANT ALL PRIVILEGES ON `testdb`.* TO 'dummyuser'@'%' |
+-----------------------------------------+
2 rows in set (0.00 sec)

第 2 步:现在我尝试了另一件事。授予用户 'dummyuser'@'bnode1' 权限,相同的命令,现在我可以访问了。

root@bnode1 /]# mysql -h 172.22.191.202 -u root -ppassword     
Welcome to the MariaDB monitor. Commands end with ; or \g.
...

MariaDB [(none)]> grant all privileges on testdb.* to '**dummyuser'@'bnode1'** identified by 'passwor>
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@bnode1 /]#
[root@bnode1 /]#
[root@bnode1 /]# mysql -h 172.22.191.202 -u dummyuser -ppassword
Welcome to the MariaDB monitor. Commands end with ; or \g.
...
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

我不是 mysql 专家,谁能给我解释一下我做错了什么。

最佳答案

ERROR 1045 (28000): Access denied for user 'dummyuser'@'bnode1' (using password: YES)

您可能需要尝试从其他主机连接以查看“bnode1”是否被“dummyuser”限制

或者您可以创建一个新用户(因为您没有显示创建用户命令,我假设它是一个现有用户)并且您执行的授权命令应该可以工作。

不太可能,但以防万一,您需要确保 my.cnf 中的 'bind=0.0.0.0'。

关于MySQL - 授予访问权限不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29176236/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com