创建mysql用户时出现警告

huwehgph  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(444)

我按照以下教程创建了一个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)

我应该输入什么命令将用户添加到Drupal8数据库?

5f0d552i

5f0d552i1#

使用 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”数据库。

相关问题