Press "Enter" to skip to content

Mysql8的用户授权

问题

部署 zabbix 时,按照文档给 mysql 做授权,出现错误

# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;

错误提示:the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'password' WITH GRANT OPTION' at line 1

原因

MySql 8 没法使用 GRANT ALL PRIVILEGES ON . TO 'ZB'@'192.168.0.145' IDENTIFIED BY 'aabbccdd' WITH GRANT OPTION;一行命令设置用户权限。
必须分两步来实现设置用户权限【先创建用户、在对该用户分配用户权限】

步骤

CREATE USER 'zabbix'@localhost  IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;

have fun!

打赏 赞(0)
微信
支付宝
微信二维码图片

微信扫描二维码打赏

支付宝二维码图片

支付宝扫描二维码打赏

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Captcha Code