Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql "grant all" vs "grant all privileges"

Tags:

mysql

what is the difference between these two commands?

GRANT ALL ON druid.* TO 'druid'@'localhost' IDENTIFIED BY 'diurd';
GRANT ALL PRIVILEGES ON *.* TO druid@'%' IDENTIFIED BY 'diurd';
like image 548
JosephSmith47 Avatar asked Oct 03 '15 10:10

JosephSmith47


People also ask

What is grant all privileges in MySQL?

To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name. * TO 'username'@'localhost';

How do I grant multiple privileges in MySQL?

In this syntax: First, specify one or more privileges after the GRANT keyword. If you grant multiple privileges, you need to separate privileges by commas. Second, specify the privilege_level that determines the level to which the privileges apply.

How do I show all privileges in MySQL?

Answer: In MySQL, you can use the SHOW GRANTS command to display all grant information for a user. This would display privileges that were assigned to the user using the GRANT command.


1 Answers

They are equivalent with respect to the privileges syntax; PRIVILEGES is optional. Source

The scope of those permissions, however, is different. One command gives privileges on all databases (*.*) and the other gives them only on tables in database druid (druid.*).

In addition, one allows connections only from localhost, but the other allows them from anywhere (%).

Finally, druid@'%' will give a syntax error; you need quotes around druid.

As a best practice, make the permissions as limited as possible (local-only, with permissions to do as little as possible in as few places as possible).

like image 142
elixenide Avatar answered Nov 22 '22 15:11

elixenide