Tony Collin
Tony Collin

Reputation: 13

Mysql: How do I GRANT SELECT on a demo database to all users

I have a demo mysql database the I would like all users to be able to see.

How do I grant SELECT on this one database to all the mysql users?

I tried:

GRANT SELECT ON demodb.* TO ''@localhost;

This seemed to run, but no change on the visability of the demodb database.

Any help?

Upvotes: 1

Views: 1531

Answers (2)

SEoF
SEoF

Reputation: 1114

Better still, your original solution should have worked, and doesn't require an extra line for every new user, but you needed to flush privileges. I used this for setting up my global DB.

INSERT INTO mysql.db (host,user,db,Select_priv,Execute_priv) VALUE
('%','','demodb','Y','Y');
FLUSH PRIVILEGES;

Upvotes: 0

Devart
Devart

Reputation: 121902

Try this query -

INSERT INTO mysql.db(host, User, Db, select_priv)
  SELECT host, user, 'demodb', 'Y' FROM  mysql.user;

Then run 'FLUSH PRIVILEGES;' to apply privileges.

Upvotes: 2

Related Questions