ERROR 1044(42000):拒绝访问用户'访客' localhost'到数据库' mamute_development'

时间:2016-02-10 01:00:33

标签: mysql

我已经阅读了有关此主题的其他问题,但无法解决我的问题,因此发布了一个新问题。

mysql> show grants;
+----------------------------------------------------------------------------------------+
| Grants for guest@localhost                                                             |
+----------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'guest'@'localhost'                                     |
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON `parks`.* TO 'guest'@'localhost' |
+----------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> grant SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON mamute_development.* to 'root'@'localhost';
ERROR 1044 (42000): Access denied for user 'guest'@'localhost' to database 'mamute_development'

为什么?数据库确实存在:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mamute_development |
| mysql              |
| parks              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

如果我尝试其他用户,我会收到同样的错误:

mysql> create user 'mamute-user'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> grant SELECT,INSERT,UPDATE,DELETE,CREATE,DROP on mamute_development.* to 'mamute-user'@'localhost';
ERROR 1044 (42000): Access denied for user 'guest'@'localhost' to database 'mamute_development'

如果重要,请参见下文:

$ sudo ls -al /usr/local/mysql/data/
Password:
total 379688
drwxr-x---   19 _mysql    _mysql       646 Feb  9 16:02 .
drwxr-xr-x   13 morpheus  wheel        442 Oct 30 10:16 ..
-rw-r-----    1 _mysql    _mysql     45643 Dec 17 08:38 my-MacBook-Pro-3170.local.err
-rw-r-----    1 _mysql    _mysql         6 Nov 30 13:52 my-MacBook-Pro-3170.local.pid
-rw-r-----    1 _mysql    _mysql        56 Oct 30 10:16 auto.cnf
-rw-r-----    1 _mysql    _mysql       709 Jan 29 16:08 ib_buffer_pool
-rw-r-----    1 _mysql    _mysql  50331648 Feb  1 09:14 ib_logfile0
-rw-r-----    1 _mysql    _mysql  50331648 Nov 30 16:02 ib_logfile1
-rw-r-----    1 _mysql    _mysql  79691776 Feb  1 09:14 ibdata1
-rw-r-----    1 _mysql    _mysql  12582912 Feb  1 09:14 ibtmp1
drwxr-x---    3 _mysql    _mysql       102 Feb  9 16:02 mamute_development
drwxr-x---   77 _mysql    _mysql      2618 Oct 30 10:16 mysql
-rw-r-----    1 _mysql    _mysql   1389508 Feb  9 16:54 mysqld.local.err
-rw-r-----    1 _mysql    _mysql         3 Feb  1 09:14 mysqld.local.pid
-rw-rw----    1 _mysql    _mysql         6 Nov 30 13:52 mysqld_safe.pid
drwxr-x---    5 _mysql    _mysql       170 Oct 30 10:50 parks
drwxr-x---   90 _mysql    _mysql      3060 Oct 30 10:16 performance_schema
drwxr-x---  108 _mysql    _mysql      3672 Oct 30 10:16 sys

我删除了root用户并再次添加回来。另见下文:

$ sudo /usr/local/mysql/bin/mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17101
Server version: 5.7.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show grants;
+------------------------------------------+
| Grants for root@localhost                |
+------------------------------------------+
| GRANT USAGE ON *.* TO 'root'@'localhost' |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'localhost';
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

0 个答案:

没有答案