Skip to main content

Grant all privileges problem

General • Asked by Jørund Jenssen Berg


I´m a total newbie and in the process of learning Ruby on Rails. So far I´ve installed Ruby (version 2.5.1) on my Mac and created a database. Now I want to create a new user to a demo project I´ve created, and grant the new user all privileges. When I entered the following code in Terminal...

mysql> GRANT ALL PRIVILEGES ON demo_project_development.* TO 'rails_user'@'localhost' IDENTIFIED BY 'secretpassword';

...I got the following error message:

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

I´ve tried looking for the manual, but I´m not quite sure what I´m looking for! So any help would be appreciated. Either by telling me how my code is not appropriate for this version, or where I can find this manual.

Thanks =)

I think maybe you're mixing commands. When you create user, you specify the password. When you grant privileges, I don't think you want the "IDENTIFIED BY PASSWORD" part.

Here's a good little blog post that explains more about it.

Thanks a lot Chris! I´ll try it out =)

It worked - thanks again!

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 20,000+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.