gpt4 book ai didi

mysql - 错误 1044 (42000) : Access denied for user

转载 作者:行者123 更新时间:2023-12-02 17:30:04 24 4
gpt4 key购买 nike

我在 MySQL 中创建了一个带密码的新用户。

mysql> GRANT ALL PRIVILEGES ON simple_cms_development.*
-> TO 'simple_cms'@'localhost'
-> IDENTIFIED BY 'xxxxxxx';
Query OK, 0 rows affected (0.04 sec)

我检查它是否已创建:

mysql> SHOW GRANTS FOR 'simple_cms'@'localhost';
+-------------------------------------------------------------------------------------------------------------------+
| Grants for simple_cms@localhost |
+-------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'simple_cms'@'localhost' IDENTIFIED BY PASSWORD '*CA931C969BFB20B345B153F9AE0B3EBC543B48EF' |
| GRANT ALL PRIVILEGES ON `simple_cms_development`.* TO 'simple_cms'@'localhost' |
+-------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

我试图以该用户身份登录并收到 1044 错误:

 Macintosh-2:simple_cms kmcrayton7$ mysql -u simple_cms -p simple_csm_development;
Enter password:
ERROR 1044 (42000): Access denied for user 'simple_cms'@'localhost' to database 'simple_csm_development'

按照回答 #1 and #6 中的步骤操作结果如下:

mysql> select user,host,password from mysql.user;
+------------+-----------+-------------------------------------------+
| user | host | password |
+------------+-----------+-------------------------------------------+
| root | localhost | *986BD1453A6B2F3CCF85DC695B981EE516B7613D |
| root | macintosh | *986BD1453A6B2F3CCF85DC695B981EE516B7613D |
| root | 127.0.0.1 | *986BD1453A6B2F3CCF85DC695B981EE516B7613D |
| root | ::1 | *986BD1453A6B2F3CCF85DC695B981EE516B7613D |
| | localhost | |
| | macintosh | |
| simple_csm | localhost | *CA931C969BFB20B345B153F9AE0B3EBC543B48EF |
| simple_cms | localhost | *CA931C969BFB20B345B153F9AE0B3EBC543B48EF |
+------------+-----------+-------------------------------------------+
8 rows in set (0.04 sec)

mysql> exit
Bye
Macintosh-2:simple_cms kmcrayton7$ mysql -u simple_cms -p simple_csm_development;
Enter password:
ERROR 1044 (42000): Access denied for user 'simple_cms'@'localhost' to database 'simple_csm_development'


[1]: https://stackoverflow.com/questions/489119/mysql-error-1045-access-denied

我不知道我哪里错了

我试图遵循下面的建议,但现在我似乎根本无法获得访问权限:

Macintosh-2:simple_cms kmcrayton7$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Macintosh-2:simple_cms kmcrayton7$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Macintosh-2:simple_cms kmcrayton7$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Macintosh-2:simple_cms kmcrayton7$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Macintosh-2:simple_cms kmcrayton7$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Macintosh-2:simple_cms kmcrayton7$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Macintosh-2:simple_cms kmcrayton7$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Macintosh-2:simple_cms kmcrayton7$

最佳答案

我遇到了同样的问题并通过以下方式解决了:

GRANT ALL PRIVILEGES ON DBName.* TO 'UserName'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

关于mysql - 错误 1044 (42000) : Access denied for user,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34568193/

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