mysql给普通用户指定数据库操作权限和指定访问数据库 |
您所在的位置:网站首页 › Mysql登陆用户查看 › mysql给普通用户指定数据库操作权限和指定访问数据库 |
1:创建普通用户 create user user_name@'%' identified by 'password'; 2:给用户授权 指定所有操作权限给用户 grant all privileges on testDB.* to 'user_name'@'localhost' identified by 'password'; //本地授权 grant all privileges on testDB.* to 'user_name'@'%' identified by 'password'; //远程授权 all 可以替换为 select,delete,update,create,drop flush privileges; #刷新系统权限表
指定部分权限给用户 grant select,update on testDB.* to 'user_name'@'localhost' identified by 'password'; flush privileges; #刷新系统权限表
如上授权可能因为mysql的版本不同会有区别,如果报错,请使用以下授权语句 GRANT GRANT OPTION ON `db_test`.* TO 'user_name'@'%'; //指定访问的数据库 GRANT SELECT ON *.* TO 'user_name'@'%' IDENTIFIED BY 'password'; //指定可以访问所有的数据库 flush privileges; #刷新系统权限表
删除用户 Delete FROM mysql.user Where user='user1'; |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |