centos7 mysql8创建用户并授权

创建用户并授权所有权限
创建用户

CREATE USER 'pxs'@'192.168.%' IDENTIFIED BY zhangsan123';

授予所有权限

GRANT ALL PRIVILEGES ON *.* TO 'pxs'@'192.168.%' WITH GRANT OPTION;
flush privileges;    

出现问题:ERROR 1410 (42000): You are not allowed to create a user with GRANT
原因:当前user表中没有root - %记录; 可以更新root - localhost 为 root - %

mysql> select user,host from user;
update user set host = '192.168.%' where user = 'pxs';

再次授权

你可能感兴趣的:(centos)