gpt4 book ai didi

mysql - 在创建该数据库后无法访问某些数据库

转载 作者:可可西里 更新时间:2023-11-01 07:59:29 24 4
gpt4 key购买 nike

作为 root@localhost

mysql> CREATE USER 'aaa'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT USAGE ON * . * TO 'aaa'@'%' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE DATABASE IF NOT EXISTS `aaa` ;
Query OK, 1 row affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON `aaa` . * TO 'aaa'@'%';
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'aaa'

这是怎么回事.. 为什么会给我这个错误?

mysql> show grants;
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*B67132C4A56F2FFFE0AA531DECF0C98895F9CB9B' WITH GRANT OPTION |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

最佳答案

我过去遇到过这个问题,我的解决方案是显式连接到 127.0.0.1 而不是本地主机别名

mysql -uroot -h127.0.0.1 

希望这对你有用!

关于mysql - 在创建该数据库后无法访问某些数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13180721/

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