首页 > 解决方案 > 无法为 MySQL 创建 bugzilla 用户

问题描述

我正在尝试在 Ubuntu 20.04 上安装 Bugzilla 5.0.6。MySQL 版本为 8.0。

对于 MySQL 配置,Linux安装指南向我介绍了此页面,其中包含创建“错误”用户的说明:

GRANT SELECT, INSERT,
UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES,
CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugs.*
TO bugs@localhost IDENTIFIED BY '$DB_PASS';

FLUSH PRIVILEGES;

当我尝试这样做时,或者在各种元素周围使用不同的间距和单引号的变体时,我总是会遇到语法错误:

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES, CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugs.* TO bugs@localhost IDENTIFIED BY '***';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY '***'' at line 1
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,CREATE,LOCK TABLES,CREATE TEMPORARY TABLES,DROP,REFERENCES ON bugs.* TO bugs@localhost IDENTIFIED BY '***';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY '***'' at line 1
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES, CREATE TEMPORARY TABLES, DROP, REFERENCES ON 'bugs'.'*' TO 'bugs'@'localhost' IDENTIFIED BY '***';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''bugs'.'*' TO 'bugs'@'localhost' IDENTIFIED BY '***'' at line 1
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,CREATE,LOCK TABLES,CREATE TEMPORARY TABLES,DROP,REFERENCES ON 'bugs'.'*' TO 'bugs'@'localhost' IDENTIFIED BY '***';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''bugs'.'*' TO 'bugs'@'localhost' IDENTIFIED BY '***'' at line 1

因此,我按照 Ubuntu 14.04快速入门指南的建议从命令行尝试了它:

mysql -u root -p -e "GRANT ALL PRIVILEGES ON bugs.* TO bugs@localhost IDENTIFIED BY '$db_pass'"

这给出了类似的错误:

$ sudo mysql -e "GRANT ALL PRIVILEGES ON bugs.* TO bugs@localhost IDENTIFIED BY '***'"
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY '***'' at line 1
$ sudo mysql -e "GRANT ALL PRIVILEGES ON 'bugs'.'*' TO 'bugs'@'localhost' IDENTIFIED BY '***'"
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''bugs'.'*' TO 'bugs'@'localhost' IDENTIFIED BY '***'' at line 1

如何创建 Bugzilla 用户?

编辑根据此处的反馈,我将命令分开:

mysql> CREATE USER 'bugs'@'localhost' IDENTIFIED BY '***';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON 'bugs'.'*' TO 'bugs'@'localhost';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''bugs'.'*' TO 'bugs'@'localhost'' at line 1
mysql> GRANT ALL PRIVILEGES ON 'bugs'.'*' TO 'bugs'@'localhost';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''bugs'.'*' TO 'bugs'@'localhost'' at line 1

现在怎么了?

编辑 2 这已被标记为问题“如何在 MySQL 8.0 中向 root 用户授予所有权限”的重复项。我的问题源于尝试遵循 Bugzilla 的指示。没有指导,我无法知道这是 Bugzilla 指令的问题,我无法知道我应该问这个问题“如何在 MySQL 8.0 中向 root 用户授予所有权限?” 因此,该问题的存在并不能帮助我或我遇到的其他任何人,尽管事实证明那里的解决方案可以解决 Bugzilla 说明中给出的错误。

标签: mysqlbugzilla

解决方案


推荐阅读