mysql对新用户授权
大致语法:
grant select,insert,update,delete on 数据库名.表名 to 授权用户@"%" identified by "新用户密码";
例如:(只给ceshi用户中的sys_log表 进行查询和添加授权)
grant select,insert on testdb.sys_log to ceshi@"%" identified by "root";
授权完成之后 可以对上述操作做一个简要的检验 看看是否授权成功
检验办法:(删除sys_log表中已经存在的一条数据)
delete from sys_log where id = 12;
如果提示如下的错误消息框 则说明授权成功
DELETE command denied to user 'ceshi'@'localhost' for table 'sys_log'
也可以再次查询sys_log表 检验发现要删除的记录仍然存在
赋予所有权限的方法:
grant all privileges on *.* to '用户名'@'ip地址' identified by '密码';