mysql - 授予权限时出错 - Mysql GRANT 已弃用,请改用 ALTER USER

标签 mysql

我正在使用最新版本的 mysql。运行以下命令时,它要求我使用 ALTER USER 命令而不是 GRANT。我看不到使用 ALTER USER 命令在任何地方更新权限的语法。 https://dev.mysql.com/doc/refman/5.7/en/alter-user.html

GRANT ALL PRIVILEGES ON *.* to 'root'@'localhost' IDENTIFIED by ‘1234’;

如有任何指点,我们将不胜感激。

最佳答案

GRANT 的文档提及:

Note

If an account named in a GRANT statement does not already exist, GRANT may create it under the conditions described later in the discussion of the NO_AUTO_CREATE_USER SQL mode. It is also possible to use GRANT to specify nonprivilege account characteristics such as whether it uses secure connections and limits on access to server resources.

However, use of GRANT to create accounts or define nonprivilege characteristics is deprecated as of MySQL 5.7.6. Instead, perform these tasks using CREATE USER or ALTER USER.

查询中的IDENTIFIED by ‘1234’部分用于设置/更改用户密码。密码不是特权,应使用 ALTER USER 进行更改。

使用:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'

向用户授予所需的权限,并且:

ALTER USER 'root'@'localhost' IDENTIFIED BY '1234'

如果需要,更改其密码。

备注

值得一提的是 ALTER USER声明是introduced in MySQL 5.6 .对于旧版本,GRANT 语句是更改用户密码的唯一方法。

关于mysql - 授予权限时出错 - Mysql GRANT 已弃用,请改用 ALTER USER,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46783415/

相关文章:

MySQL InnoDB : what are the units for "reads/s"?

php - 在 MySQL 中是否有等效于 PHP 的 `date_default_timezone_set()` 的东西?

mysql - 按天计算答案 mySQL

Java:createQuery 返回 null

php - 与本地主机数据库的连接问题

php - 您是否在 form_validation 之后发布输入值?

mysql - 如何统计每天发给不同人的消息数量?

python - sqlalchemy group_by 和求和

php - mysql_fetch_array() 不工作,没有错误

mysql - 排序记录并在顶部获取非空记录