3

I'm trying to execute the below command as root user to provide accessiblity from my application.

GRANT ALL ON communitycourts.* TO 'root'@'%' WITH GRANT OPTION;

But it returns 0 rows affected, but when I dont see this in result of SHOW GRANTS. Pelase help me

3
  • Do you have the communitycourts database? Is it spelled exactly as in your command? Feb 21 '12 at 12:40
  • Are you using root for your application? Why?
    – gbn
    Feb 21 '12 at 12:58
  • @gbn I have changed to other user now Feb 21 '12 at 13:48
4

Two points to add:

  1. It is recommended to use another user other than root to connect to your DB in your application. Try to use root account for administration only. This can be good only on testing machines.
  2. Don't forget to flush privileges for the changes to take effect. This is better than restarting mysql.
1
  • As you recommended, I created a another and given grant previleges to that user. It works now. Thanks Feb 21 '12 at 13:47
2

0 rows affected is normal for a successful GRANT command. Unsuccessful ones will display an error.

If you see 1 warning after 0 rows affected you should type SHOW WARNINGS; and check whether the warning affects you or not. This one could:

Warning | 1285 | MySQL is started in --skip-name-resolve mode; you must restart it without this switch for this grant to work

The SHOW GRANTS command will only show the privileges that the user executing the command has. If you are logged in as root@localhost or root@192.168.0.1 then you won't see the grants for root@%.

Try SHOW GRANTS FOR 'root'@'%'; instead.

1

Either

  • communitycourts doesn't exist
  • 'root'@'%' doesn't exist

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.