Monday 22 July 2013

MySQL root user can't grant privileges

Today setup MySQL for developers, when I try to create a new user for application, encounter  1045 error , it's because the root user dun have GRANT_PRIV rights. I paste the solution here.

mysql> grant all privileges on *.* to 'ipservice_usr'@'192.*.*.*' identified by '********';
ERROR 1045 (28000): Access denied for user
'root'@'localhost' (using password: YES)
mysql> show grants for
'root'@'localhost';
+----------------------------------------------------------------------------------------------------------------------+
| Grants for
root@localhost                                                                                            |
+----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO
'root'@'localhost' IDENTIFIED BY PASSWORD '**************' |
| GRANT PROXY ON
''@'' TO 'root'@'localhost' WITH GRANT OPTION                                                         |
+----------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM mysql.user WHERE User='root' and Host='localhost'\G
*************************** 1. row ***************************
                  Host: localhost
                  User: root
              Password: ****************
           Select_priv: Y
           Insert_priv: Y
           Update_priv: Y
           Delete_priv: Y
           Create_priv: Y
             Drop_priv: Y
           Reload_priv: Y
         Shutdown_priv: Y
          Process_priv: Y
             File_priv: Y
            Grant_priv: N
       References_priv: Y
            Index_priv: Y
            Alter_priv: Y
          Show_db_priv: Y
            Super_priv: Y
 Create_tmp_table_priv: Y
      Lock_tables_priv: Y
          Execute_priv: Y
       Repl_slave_priv: Y
      Repl_client_priv: Y
      Create_view_priv: Y
        Show_view_priv: Y
   Create_routine_priv: Y
    Alter_routine_priv: Y
      Create_user_priv: Y
            Event_priv: Y
          Trigger_priv: Y
Create_tablespace_priv: Y
              ssl_type:
            ssl_cipher:
           x509_issuer:
          x509_subject:
         max_questions: 0
           max_updates: 0
       max_connections: 0
  max_user_connections: 0
                plugin: mysql_native_password
 authentication_string:
      password_expired: N
1 row in set (0.00 sec)


mysql> update mysql.user set grant_priv='Y' where user='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 3  Changed: 2  Warnings: 0

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

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,grant_priv from mysql.userl
    -> ;
ERROR 1146 (42S02): Table 'mysql.userl' doesn't exist
mysql> select user,grant_priv from mysql.user;
+------+------------+
| user | grant_priv |
+------+------------+
| root | Y          |
| root | Y          |
| root | Y          |
+------+------------+
3 rows in set (0.00 sec)

mysql> exit
Bye
[root@IBM-09 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.11-log MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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> grant all privileges on *.* to 'ipservice_usr'@'********' identified by '********';
Query OK, 0 rows affected (0.00 sec)

mysql>


No comments:

Post a Comment