创建MySQL用户时出现警告

时间:2018-08-16 19:53:12

标签: mysql database ubuntu-18.04

我按照以下教程创建了一个MySQL数据库和一个用户:

https://linuxize.com/post/how-to-install-drupal-on-ubuntu-18-04/

CREATE DATABASE drupal CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON drupal.* TO 'drupaluser'@'localhost' IDENTIFIED BY 'change-with-strong-password';

创建数据库有效。

但是创建用户时会收到警告:

Query OK, 0 rows affected, 1 warning (0.00 sec)

这是细节:

mysql> SHOW WARNINGS;
+---------+------+------------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                            |
+---------+------+------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1287 | Using GRANT for creating new user is deprecated and will be removed in future release. Create new user with CREATE USER statement. |
+---------+------+------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

作为将用户添加到我的Drupal 8数据库的命令,我应该输入什么?

1 个答案:

答案 0 :(得分:1)

不建议使用GRANT快速创建用户,以后将其删除。

因此,创建一个用户,然后为其授予特权。

创建用户:

CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'change-with-strong-password';

授予特权:

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES ON drupal.* TO 'drupaluser'@'localhost';

Ps :应该在执行这些命令之前创建'dupal'数据库。