数据库创建用户和受权限
# 在数据库创建一个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;
"""
本文来自博客园,作者:{Mr_胡萝卜须},转载请注明原文链接:https://www.cnblogs.com/Mr-fang/p/16448766.html

浙公网安备 33010602011771号