37
show grants for charm@'localhost';

---------------------+
| Grants for charm@localhost                                                                                   |
+-----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'charm'@'localhost' IDENTIFIED BY PASSWORD '*EDD1CD76B1331E363B2BAED3F0B7EAF28559FBEWD' |
| GRANT ALL PRIVILEGES ON `charmstyle_com`.`charmstyle_com` TO 'charm'@'localhost' 

i used

grant all on charmstyle_com to charm@'localhost' IDENTIFIED BY 't1q4gytrur';
flush privileges;

then i import the database,it shows an error:

   ERROR 1142 (42000) at line 29: CREATE command denied to user 'charm'@'localhost' for table 'adminnotification_inbox'
William Perron
  • 485
  • 7
  • 16
37336792
  • 473
  • 1
  • 6
  • 13

1 Answers1

51

You granted the user permissions only to the 'charmstyle_com' table inside the 'charmstyle_com' database. What you probably want is to grant permissions to all the tables in 'charmstyle_com' (or at least the 'adminnotification_inbox' table)

 GRANT ALL PRIVILEGES ON `charmstyle_com`.* TO 'charm'@'localhost' 

alternatively

 GRANT ALL PRIVILEGES ON `charmstyle_com`.`adminnotification_inbox` 
     TO 'charm'@'localhost' 
scibuff
  • 13,377
  • 2
  • 27
  • 30
  • At least in my case, the privileges where only applied after i re-logged with the corresponding user; maybe this is something to add to the answer. – Philipp Ludwig Oct 26 '22 at 15:21
  • 1
    (In MySQL) Executing account management statements (grant, revoke, set password, etc) causes the grant tables to be reloaded immediately. If you modify the grant tables directly (e.g. via insert, update, etc) you need to load them into memory manually. However, changes to tables/column take an effect immediately. Changes to databases require `use ` to refresh - see: https://dev.mysql.com/doc/mysql-security-excerpt/8.0/en/privilege-changes.html – scibuff Oct 31 '22 at 11:48