mysql forgets who is logged in: command denied to user ''@'%'

后端 未结 3 1871
悲哀的现实
悲哀的现实 2020-12-09 11:00

Running show grants; indicates that I am logged in as a user with all privileges on a database.

Running show table status; results in an er

相关标签:
3条回答
  • 2020-12-09 11:42

    Take schema backup before proceeding.

    If you just imported a dump file in mysql, delete that import and related schema and start again.

    open the dump file in a text editor and delete all lines with the following content /*! ~~~~ DEFINER='root' @'%' SQL SECURITY DEFINER */

    ~ Represents a random number generated by workbench during export

    This solution is a quick fix and intended for development environments only.

    0 讨论(0)
  • 2020-12-09 11:43

    The answers here helped me with my specific problem. Many thanks! A view was the culprit as described above.

    I got into trouble because the database in question was created from a backup of a remote database which had different users. The 'broken' view was 'defined' by a user I didn't have locally. Even root was unable to run the crashing query.

    Changed the view's 'DEFINER' to a valid local user and the problem was solved!

    ALTER 
    DEFINER = 'a_valid_user'@'localhost' 
    VIEW my_view
    AS 
    SELECT ..... 
    

    Check out ALTER VIEW documentation for MySQL 5.5

    Many thanks again!

    0 讨论(0)
  • 2020-12-09 11:49

    The issue is probably that you have VIEWS in your database. The views are probably created with specific rights.

    As you can tell by your error message, it complains about a different user than the one you are logged in is. This is because for a view you can specify how to determine what rights the view has to look at data.

    When you go to your database, try typing:

    SHOW FULL TABLES IN sunflower_work WHERE TABLE_TYPE NOT LIKE '%table%';
    

    Then you may wish to look into the rights of the specific views that are there.

    0 讨论(0)
提交回复
热议问题