MYSql Capabilities

Hello all.

I need some help configuring mysql. When creating a user, I noticed that I cannot create a user that was allowed to create, edit, or delete their own dbs unless I grant them those capabilities. When I do grant them those capabilities, they were able to access all the other db that they didn't own. How can I limit their access to only their dbs and give them the ability to create, edit, and delete only their dbs.

Is it by adding a host? so that they're all not just from localhost? If so, how do I get that to work? I've added the host and assigned the user to the host; but when accessing the db with that username, I can't access it with the host domain nor can I access mysql using localhost. I hope I am clear.

I would also appreciate the help. Thanks

John

3 Replies

#mysql -u root -p > Create Database databasename; (should respond OK)

Grant ALL privileges on databasename.* to username@localhost Identified by “user-password”;

(should respond OK)

Flush Privileges; (should respond OK)

Exit (should respond with BYE)

Yes, this is exactly what I did; however that user isn't able to create another database nor delete another databases that was created by that user.

The goal is to have the user create his own databases and also be able to edit and delete the user's created databases without having the power to edit or delete another user's databases.

Thanks!

You can do something like this:

GRANT ALL PRIVILEGES ON dbprefix_% . * TO 'user'@'localhost';

This should allow them to create/delete any database with name of the form "dbprefix_".

I don't think there is a way to restrict a MySQL user to being able to delete only databases that they create. Meaning that if they can create a database with any name, they can also delete one with any name (I.E. they have root powers now).

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct