Bimal Poudel
Bimal Poudel

Reputation: 1234

Granting permissions in MySQL to tables with certain prefixes

What can be the quickest way to grant permissions to a mysql table with certain prefixes?

GRANT ALL ON prefix_*.* to ''@'';

Any help is most welcome.

I believe, it is be a common problem.

Upvotes: 0

Views: 125

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1271091

Instead of using table prefixes, put the tables in separate databases. That is, work with the database, using its build-in mechanisms. MySQL makes it easy to grant access to all tables in a database. This has the additional advantage that as new tables are added into each database, the permissions just work. You don't have to keep going back and fiddling with permissions to add tables.

If you go down your path of using prefixes, I think you will need to use prepared statements.

Upvotes: 1

Bimal Poudel
Bimal Poudel

Reputation: 1234

Makes some senses. I do not have limitations on number of databases I can make and use. Not dreaming this on shared systems at all.

Separating some tables to new database will have less efforts in permission management.

Upvotes: 0

Related Questions