mysql本地数据库新建用户赋权

对单个数据库的操作权限

CREATE USER 'localadmin'@'%';
ALTER USER 'localadmin'@'%'
IDENTIFIED BY 'localadmin' ;
GRANT Event ON *.* TO 'localadmin'@'%';
GRANT Create tablespace ON *.* TO 'localadmin'@'%';
GRANT Super ON *.* TO 'localadmin'@'%';
GRANT Shutdown ON *.* TO 'localadmin'@'%';
GRANT SYSTEM_USER ON *.* TO 'localadmin'@'%';
GRANT INNODB_REDO_LOG_ARCHIVE ON *.* TO 'localadmin'@'%';
GRANT Show databases ON *.* TO 'localadmin'@'%';
GRANT Alter ON localadmin.* TO 'localadmin'@'%';
GRANT Create ON localadmin.* TO 'localadmin'@'%';
GRANT Create view ON localadmin.* TO 'localadmin'@'%';
GRANT Delete ON localadmin.* TO 'localadmin'@'%';
GRANT Drop ON localadmin.* TO 'localadmin'@'%';
GRANT Grant option ON localadmin.* TO 'localadmin'@'%';
GRANT Index ON localadmin.* TO 'localadmin'@'%';
GRANT Insert ON localadmin.* TO 'localadmin'@'%';
GRANT References ON localadmin.* TO 'localadmin'@'%';
GRANT Select ON localadmin.* TO 'localadmin'@'%';
GRANT Show view ON localadmin.* TO 'localadmin'@'%';
GRANT Trigger ON localadmin.* TO 'localadmin'@'%';
GRANT Update ON localadmin.* TO 'localadmin'@'%';
GRANT Alter routine ON localadmin.* TO 'localadmin'@'%';
GRANT Create routine ON localadmin.* TO 'localadmin'@'%';
GRANT Create temporary tables ON localadmin.* TO 'localadmin'@'%';
GRANT Execute ON localadmin.* TO 'localadmin'@'%';
GRANT Lock tables ON localadmin.* TO 'localadmin'@'%';
FLUSH PRIVILEGES;


全局属性权限

GRANT ROLE_ADMIN ON . TO ‘localadmin’@’%’;
GRANT Super ON . TO ‘localadmin’@’%’;
GRANT Drop role ON . TO ‘localadmin’@’%’;
GRANT Create user ON . TO ‘localadmin’@’%’;
GRANT Create role ON . TO ‘localadmin’@’%’;
FLUSH PRIVILEGES;

tips

新建数据库时需要选择charset 和 collation 建议使用utf8mb4 等价于UTF-8

你可能感兴趣的:(编程开发)