功能需要来源:
有一个数据库,需要做数据处理,并且做第三方库,提供给其他企业使用,这里肯定不能给root帐户,而且也只能开发当前数据库,其他数据库隐藏.
一、数据库基于5.7开发的,命令较于5.6有细微变化
1、创建普通用户:
grant select on test to test2@"%" identified by 'youPassword'
、test.area:test:为你的数据库。
、% 是所以IP可以访问,也可以指定IP访问
、这里可能会爆密码强度问题 : qwer123$ 这种格式就可。
2、用工具连接数据库,输入刚刚创建的test2为用户名,youPassword 为用户密码,增、删、查、改一下,
你会发现,只能查询有效,(下面这里是 增、删、查、改 所有功能)
grant select,update,delete,insert on test to test2@"%" identified by 'youPassword'
现在是不是觉得已经解决了问题了,但是如果你想限制到表的时候
正确事例
grant select on test.area to test2@"%" identified by 'youPassword'
上面这个语句是可以解决问题,但是
错误事例:
grant select on test.area,test.area1 to test2@"%" identified by 'youPassword'
你想像上面那样加个 ,就以为解决了,那是不存在的。
2.1 首先使用正确事例,进行单张表的限制,
grant select on test.company_basic_info to test2@"%";
在单张表的基础之上进行修改添加,虽然有点麻烦。但是问题解决了。
下面这个是解决资料参考:
https://www.cnblogs.com/flying1819/articles/9077059.html
https://blog.csdn.net/maxsky/article/details/51171474
https://www.cnblogs.com/jinanxiaolaohu/p/10613252.html
https://www.cnblogs.com/tongxiaoda/p/7867796.html
https://segmentfault.com/q/1010000010753068
https://developer.aliyun.com/article/272366