is there a way to set password for each db in MySQL?
Asked Answered
C

1

6

Is there a any way to set password for each database in MySQL server . if there , give some suggestions.

Crowell answered 30/9, 2012 at 5:16 Comment(2)
passwd for db or passwd for user ?Androcles
you have the answer from JimpAndrocles
A
7

You cannot set passwords on MySQL databases. You can set passwords for users with privileges granted per database, table, etc.

CREATE USER Syntax

CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';

GRANT Syntax

GRANT ALL ON db1.* TO 'jeffrey'@'localhost';
GRANT SELECT ON db2.invoice TO 'jeffrey'@'localhost';
GRANT USAGE ON *.* TO 'jeffrey'@'localhost' WITH MAX_QUERIES_PER_HOUR 90;

That should help get you started.

Able answered 30/9, 2012 at 5:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.