Search code examples
mysqlsqldatabasewordpresssql-grant

Trying to setup wordpress on ubuntu and want to grant privileges in mysql


Trying to run this:

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
    -> ON wordpress.*
    -> TO wordpress@localhost
    -> IDENTIFIED BY 'root';

But got 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 'root'' at line 4

Is there any version issue. What is the alternative to do this?


Solution

  • The grant command does not accept an identified by clause. If you want to create the user, you need to do it in a separate statement, then grant it the relevant privilieges:

    CREATE USER wordpress@localhost IDENTIFIED BY 'root';
    
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER
        ON wordpress.*
        TO wordpress@localhost;