【问题标题】:MySQL ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versionMySQL ERROR 1064 (42000):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册
【发布时间】:2019-11-22 19:15:13
【问题描述】:

当我尝试在 mySQL 上为用户授予权限时,发生了错误。我在命令行上输入了什么错误吗?

mySQL Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)。

mysql>grant all privileges on librarydb.* to 'phill'@'%' identified by '123456';
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 '123456'' at line 1.

【问题讨论】:

  • 只尝试这么多grant all privileges on librarydb.* to 'phill'@'%';
  • identified by 子句用于在创建用户期间定义密码。正如@SumitBadaya 建议的那样摆脱它。
  • @SumitBadaya 哇,它有效!非常感谢!但是为什么在这种情况下我不需要通过密码来识别呢?
  • @BarbarosÖzhan 我知道了,谢谢你的帮助!
  • alter user librarydb 标识为 '123456' 以更改密码。

标签: mysql privileges


【解决方案1】:

您的 MySQL 是什么版本?如果是5.7或更高版本,可能和这个问题一样:

Unsuccessfully granting privileges

【讨论】:

    【解决方案2】:

    下一条命令

    mysql>grant all privileges on librarydb.* to 'phill'@'%' identified by '123456';
    

    应改为:

    mysql> create user 'phill' identified by '123456';
    mysql> grant all privileges on librarydb.* to 'phill';
    

    如果尚未创建“菲尔”用户。如果之前已创建,则使用alter 而不是create

    【讨论】:

      猜你喜欢
      • 2021-12-03
      • 2018-11-09
      • 2014-03-14
      • 2018-04-04
      • 2017-09-12
      • 1970-01-01
      • 2014-03-27
      • 1970-01-01
      • 2014-01-27
      相关资源
      最近更新 更多