0

Where is the syntax error in my SQL statement?

mysql> grant all privileges on blog_demo_com.* to 'wordpress'@'localhost' identified by 'wordpress#demo';  
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 'wordpress#demo'' at line 1
mysql> 

I checked my SQL statement I really cannot find the issue.


EDIT-01

my MySQL version:

mysql  Ver 8.0.25 for Linux on x86_64 (MySQL Community Server - GPL)
user7693832
  • 6,119
  • 19
  • 63
  • 114
  • you don't need to add the identified by part , try it this way grant all privileges on blog_demo_com.* to 'wordpress'@'localhost' you can refer to this answer https://stackoverflow.com/questions/5016505/mysql-grant-all-privileges-on-database – Fatiha IMOUSSAINE Aug 25 '21 at 13:08

1 Answers1

0

The identified by syntax is not supported by MySQL 8.x: https://dev.mysql.com/doc/refman/8.0/en/grant.html

GRANT
    priv_type [(column_list)]
      [, priv_type [(column_list)]] ...
    ON [object_type] priv_level
    TO user_or_role [, user_or_role] ...
    [WITH GRANT OPTION]
    [AS user
        [WITH ROLE
            DEFAULT
          | NONE
          | ALL
          | ALL EXCEPT role [, role ] ...
          | role [, role ] ...
        ]
    ]
}
Ian Kemp
  • 28,293
  • 19
  • 112
  • 138