数据库
首页 > 数据库> > 数据库创建用户和受权限

数据库创建用户和受权限

作者:互联网

# 在数据库创建一个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;
"""

标签:grant,创建,数据库,identified,Luffy123,api,luffy,权限,localhost
来源: https://www.cnblogs.com/Mr-fang/p/16448766.html