简体   繁体   中英

MySQL database level credentials

Is it possible to have database level credentials for MySQL?

In our current system we have multiple databases in one database server, if we connect to the server using any tool we can see all databases in that server, to have more secure system.

Can we have credentials for each database.

You can't have credentials for databases. But you can have credentials for created users and grant/restrict access to any tables/databases according your policy.

create user

grant

priviledges

Yes, absolutely, you can set up access privileges on per-database basis. In fact, MySQL allows very fine-grained privileges down to table and even column level. Eg:

-- Creates a user
GRANT USAGE ON *.* TO 'username'@'hostname' IDENTIFIED BY PASSWORD '*SOMEPASSWORD';

-- Gives the user access to a single database `database_name`
GRANT SELECT, INSERT, UPDATE, DELETE ON `database_name`.* TO 'username'@'hostname';

You probably want to read more about GRANT syntax and MySQL privileges .

Worth adding, that you are allowed to have usernames identical to database names.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM