2010-11-04 52 views
1

我在朋友之間建立了共享Web服務器設置。每個網站都有自己的數據庫。我希望能夠將每個數據庫的用戶管理委派給數據庫的所有者。這樣他們就可以爲他們的Web應用程序創建賬戶來訪問他們特定的表格,但如果特定的應用程序受到攻擊,它們也不會四處遊蕩。mysql:具有授權選項的數據庫特定用戶權限委託

爲了進一步通過舉例的方式澄清一下,我想是這樣的:

Database server at : db.hosting.coop 
db root user : [email protected] <full permissions as root> 

website and database 1: foo.com 
foo.com db user : [email protected] <full permissions on database foo, with ability to grant user access to database foo, granted by [email protected]> 
foo.coms rails app db user : [email protected] <select,insert,update,delete on foo.*, granted by [email protected]> 

website and database 2: bar.com 
bar.com db user : [email protected]% <full permissions on database foo, with grant, granted by [email protected]> 
bar.coms php app db user : [email protected] <select,insert,update,delete on bar.*, granted by [email protected]> 

回答

1

以root身份:

GRANT CREATE USER ON *.* TO 'foo'@'%'; 
GRANT ALL PRIVILEGES ON `foo.com`.* TO 'foo'@'%' WITH GRANT OPTION; 

爲Foo:

CREATE USER 'foorails'@'%' IDENTIFIED BY 'secret'; 
GRANT SELECT ON `foo.com`.* TO 'foorails'@'%' 
與他人

同樣

+0

輝煌。謝謝。完全按照我的希望工作。 – voxobscuro 2010-11-05 04:48:34