开发者

MySQL: Create user with rights only for specific db [duplicate]

This question already has answers here: Create new user in MySQL and give it full access to one database (9 answers) Closed 6 years ago.

I would need to create MySQL user programatically with the privileges only for sp开发者_如何学Cecific db. Say there are databases a,b,c and I would need to create user who has rights only for B. I am sure its possible but my googling was not successful. Thank you!


grant all
    on B.*
to
    'user'@localhost
identified by
    'password'

The user 'user' with password 'password' now have access to all tables in the database 'B'. (Of course you need to run this query with a high priv user)


you can try this

 CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'some_pass';
 grant all privileges on B.* to 'myuser'@'localhost' identified by 'some_pass';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜