数据库创建用户和受权限

# 在数据库创建一个luffy用户,密码是Luffy123?,只能对luffy_api库有操作权限
-查看数据库的用户:select user,host,authentication_string from mysql.user;
-创建用户;grant 权限(create, update) on 库.表 to '账号'@'host' identified by '密码'
grant all privileges on luffy_api.* to 'luffy'@'%' identified by 'Luffy123';
grant all privileges on luffy_api.* to 'luffy'@'localhost' identified by 'Luffy123';
"""
如MySQL版本在5.7以上时,创建用户和权限要分开设不然会报错:
ip地址
create user luffy@"%" identified by "Luffy123";
grant all on luffy_api.* to luffy@"%" with grant option;
本地localhost
create user luffy@"localhost" identified by "Luffy123";
grant all on luffy_api.* to luffy@"localhost" with grant option;
"""
posted @   Mr_胡萝卜须  阅读(54)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示