如何设置mysql用户的权限

1.创建一个新用户并以root用户登录。
创建>>grantallprivilegeson*.*totestuser@localhostidentifiedby"123456";//创建一个新用户,用户名为testuser,密码为123456>>grantallprivilegeson*.*totestuser@localhostidentifiedby"123456";//设置用户testuser,可以本地访问mysql>>grantallprivilegeson*.*totestuser@"%"identifiedby"123456"//设置用户testuser,可以远程访问mysql>>flushprivileges;//在mysql中设置新用户或更改密码后,需要使用flushprivileges更新MySQL系统权限表。
否则,访问将被拒绝。
另一种方法是重新启动mysql服务器来进行新的设置2.设置用户对数据库的访问权限>>grantallprivilegesontest_db.*totestuser@localhostidentedby"123456";//设置用户testuser,只能访问test_db数据库,不能访问其他数据库;>>授予所有权限*.*totestuser@localhostidentifiedby“123456”;访问mysql数据库上的所有数据库;>>grantallprivilegesontest_db.user_infortotestuser@localhostidentifiedby"123456";//设置用户testuser,只能访问test_db数据库的user_infor表,不能访问数据库中的其他表。
3、设置用户的操作权限>>grantallprivilegeson*.*totestuser@localhostidentifiedby"123456"WITHGRANTOPTION//设置用户testuser,拥有所有操作权限,即管理员>>grantselecton*.*totestuser@localhostidentifiedby"1234;56"授予选择权;//设置用户testuser,只有【查询】操作权限;>>grantselect,inserton*.*totestuser@localhostidentifiedby"123456";//设置用户testuser,仅具有【查询\插入】操作权限;>>grantselect,insert,update,deleteon*.*totestuser@localhostidentifiedby"123456"//设置testuser用户只有操作权限[query\insert]>>REVOKEselect,insertONwhatFROMtestuser//取消操作权限[query\insert]用户testuser;

mysql命令如何修改一个用户的权限为%

UPDATEmysql.userSETHOST='%'WHEREUSER='您的用户名';