0

I have already read other questions on this topic but couldn't solve my problem hence posting a new question.

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'

Why?? The database does exist:

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

If I try another user, I get same error:

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'

Also see below, in case it matters:

$ 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

I had deleted root user and added it back again. Also see below:

$ 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)
morpheus
  • 18,676
  • 24
  • 96
  • 159
  • Your guest account doesn't have permissions to update the root account's permissions. Pretty straightforward, and seems perfectly reasonable from a security perspective. – miken32 Feb 10 '16 at 01:05
  • guest account seems to have permissions: GRANT ALL PRIVILEGES ON *.* TO 'guest'@'localhost' – morpheus Feb 10 '16 at 01:08
  • [`ALL PRIVILEGES` does not mean all privileges](http://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html#priv_all). It means all but the ability to alter other users. – miken32 Feb 10 '16 at 01:19
  • Possible duplicate of [Restoring deleted 'root' user and password for MySQL](http://stackoverflow.com/questions/6085455/restoring-deleted-root-user-and-password-for-mysql) – miken32 Feb 10 '16 at 01:24
  • I am screwed. I deleted the root (admin) account. The guest user does not have grant option and when I try to add that option I get another access denied error. mysql> grant all privileges on *.* to 'guest'@'localhost' with grant option; ERROR 1045 (28000): Access denied for user 'guest'@'localhost' (using password: YES) – morpheus Feb 10 '16 at 01:25
  • I don't know anyone could delete the root user, but see the dupe for your solution. BTW you'd have a hell of a problem if any user could grant themselves any privileges! – miken32 Feb 10 '16 at 01:27
  • this is just my local db. looking at the link you posted. thanks – morpheus Feb 10 '16 at 01:28

0 Answers0