2

I follow the instructions grant database privileges to rails. I used the following code:

GRANT ALL PRIVILEGES ON demo_proejcts_development.* TO'rails_user'@'localhost' IDENTIFIED BY PASSWORD 'password'

The demo_proejcts_developments is a database I created and I want to grant the privileges to the rails_user account

But it gives me an error,

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 PASSWORD 'password'' at line 1

I have tried to use ` to cover the project name, `demo_projects_development`, but it stills failed.

And more, I tried to separate the comment as two line via 'alter user', it still failed.

jarlh
  • 42,561
  • 8
  • 45
  • 63
Cvanzy
  • 382
  • 3
  • 11
  • did you check this solution? https://stackoverflow.com/questions/36099028/error-1064-42000-you-have-an-error-in-your-sql-syntax-want-to-configure-a-pa?rq=1 – Nezir Sep 30 '18 at 19:34
  • 1
    I have tried it, but they are not too similar – Cvanzy Sep 30 '18 at 21:52

1 Answers1

4

You can not use the IDENTIFIED BY in GRANT statement. check mysql documentation here

If you don't have the rails_user already set then you can create with

CREATE USER 'rails_user'@'localhost' IDENTIFIED BY 'password';

and with following statement you can give permission for all priviledges with

GRANT ALL ON demo_proejcts_development.* TO 'rails_user'@'localhost';
Sandesh Jain
  • 704
  • 3
  • 13