Press "Enter" to skip to content

Mysql8的用户授权

Last updated on 2020年5月9日

问题

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

# mysql -uroot -p

mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> flush privileges;
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;一行命令设置用户权限。
必须分两步来实现设置用户权限【先创建用户、在对该用户分配用户权限】

步骤

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

have fun!

发表评论

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

Captcha Code

提示