3

I have a global database, as I all users should have access to it. Is it possible to grant permission on a database to all users? something like

GRANT ALL ON my_database.* TO *@localhost;

Even (for security reason), it can be read permission only.

1

2 Answers 2

4

Yes, this is possible, though not recommended. You can create a user with an empty string as username, also known as the anonymous user. It matches any username. This is the only possibility, wildcards like in the hostname (i.e. 'user'@'%.any.domain.de') are not allowed.

GRANT ALL ON my_database.* TO ''@'localhost';
2

Annonymous user access means you can connect to your MySQL server without specifying any user name, this is not recommended in production environment, you should immediately remove anonymous user account from MySQL server.

You should always grant permission for each MySQL user based on their requirement for a specific database or table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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