Question

I want to code an application which, when it runs for the first time on a user's machine, will create a new database, then create a new user and grant it access to the database.

I can manage that, but I want only that user and no other to be able to access the database.

So, just in case the existing installation has superuser where root has access to everything, I would like to revoke for all but the newly created user.

How do I do that?

I am guessing something like

REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysql.user WHERE user<>[single user name] but can't seem to get it right.

I guess that I have to FLUSH PRIVILEGES afterwards?

Was it helpful?

Solution

You can ONLY give privileges to access database for your user - using GRANT command.

All other users, except root users, should not have such privileges.

Do you need to run FLUSH PRIVILEGES after GRANT/REVORE? No, you do not need. That is all)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top