Why is GRANT not working in MySQL?

后端 未结 4 1171
伪装坚强ぢ
伪装坚强ぢ 2020-12-13 05:58

I\'m scratching my head on this one as I see a ton of helper websites showing how to create MySQL users and grant privileges but for some reason it just does not work for me

相关标签:
4条回答
  • 2020-12-13 06:22

    This should work:

    GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
    
    0 讨论(0)
  • 2020-12-13 06:25

    what you are selecting are the global privileges. you are however giving database (and host, but that doesnt matter) specific privileges.

    GRANT INSERTON wordpress.* TO 'www'@'localhost' IDENTIFIED BY 'basic';

    theese permissions are stored in the db table.

    just to point you in the right direction:

    SHOW GRANTS FOR 'www'@'localhost'
    

    http://dev.mysql.com/doc/refman/5.0/en/show-grants.html

    0 讨论(0)
  • 2020-12-13 06:36

    You need to look at mysql.db or mysql.tables_priv tables if you need to select the Y or N if you are trying to do some restrictions of from what page a user can edit or insert or delete... This tables are automatically updated with the Ys and Ns as they are solely designed to show what privileges a user has on tables or columns as opposed to mysql.user whose purpose is to show that there is a certain user who can login(create connection) to a database.

    0 讨论(0)
  • 2020-12-13 06:46

    That's not where the most user GRANTed rights are stored - try

    SHOW GRANTS FOR 'www'@'localhost'
    

    to see database-specific permissions instead. (A grant would only show up in the user table if it was for all databases.)

    Here's a (rather old) step-by-step detail of how permissions are stored in MySQL - I don't think things have changed much.

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