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';
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';
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With