Can I grant access to databases with prefix then wild card?

后端 未结 1 1199
面向向阳花
面向向阳花 2020-12-24 05:42

Can I GRANT ALL PRIVILEGES ON a*.* TO \'my_user\'@\'%\' WITH GRANT OPTION; ?

I just want the user to only have access to all databases beginning with \"

相关标签:
1条回答
  • 2020-12-24 06:03

    Yes, you can.

    This is what phpMyAdmin does when I make a user jaap and use the option Grant all privileges on wildcard name (username\_%):

    GRANT ALL PRIVILEGES ON  `jaap\_%` . * TO  'jaap'@'localhost';
    

    That's what you mean, right?

    PS
    As you can see, the _ is escaped, because in (My)SQL an unescaped _ means 'one character'. (Like . in regex.) In this case, you want the _ to be literal, so databases must start with jaap_

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