简体   繁体   English

向用户授予一个数据库问题的特权

[英]Grant privileges to user for one database issue

I am new to MySQL. 我是MySQL的新手。 I have Created one user for "root" login, I want to give all privileges for only one database to this user. 我已经为“ root”登录创建了一个用户,我只想向该用户授予一个数据库的所有特权。 I tried it : 我尝试过这个 :

GRANT ALL ON db.* to userx IDENTIFIED BY 'xyz';

but it gives error: 但它给出了错误:

Error Code: 1044. Access denied for user 'root'@'%' to database 'db' 错误代码:1044。拒绝用户'root'@'%'对数据库'db'的访问

I checked rights for root user by select * from mysql.user; 我通过select * from mysql.user;检查root用户的权限select * from mysql.user; , root user has all rights. ,root用户拥有所有权利。

Can anyone pls help with this issue? 有人可以帮助解决这个问题吗?

Try userx with the format 'user'@'location'. 尝试使用'user'@'location'格式的userx。 If you are on a local database, for example. 例如,如果您在本地数据库上。

GRANT ALL ON db.* TO 'user'@'localhost' IDENTIFIED BY 'xyz';

Take care with that '@' in the middle. 注意中间的“ @”。

login with your root and password and then click on the database you want to give priviledges now go to priviledges tag and click on add user provide the username password and hosttype for and then go to "database for user section" and check the option 使用您的root和密码登录,然后单击要授予特权的数据库,现在转到priviledges标记,然后单击添加用户,为其提供用户名密码和主机类型,然后转到“用户数据库部分”并选中选项

  Grant all privileges on database "yourdatabasename" 

and then click on go button. 然后单击“执行”按钮。 See usage is mentioned on the database after that logout from root and login with the given username and password. 从根注销并使用给定的用户名和密码登录后,请参阅数据库上提到的用法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM