問題描述
WordPress(“5 Minutes”) 的簡短安裝説明指出:
Create a database for WordPress on your web server, as well as a MySQL user who has all privileges for accessing and modifying it.
在專業設置一個新博客時,我想知道如何映射到 MySQL 數據庫用户權限/權限配置為我提供的功能:
- 數據:
SELECT,INSERT,UPDATE,DELETE - 定義:
CREATE,ALTER,DROP - 額外:
INDEX -
更多:
-
LOCK TABLES -
REFERENCES -
CREATE TEMPORARY TABLES -
CREATE VIEW -
SHOW VIEW -
CREATE ROUTINE -
EXECUTE -
ALTER ROUTINE
-
我非常確定前三組,我在這裏命名為 「數據,定義和附加」 。但是更多條目下面的其他人呢?通常我會説,那些不是必需的,但我想得到第二個意見。
最佳解決方案
你指出的其他人是不需要的。
Btw,您可以做的是根據請求的頁面有條件地設置用户/傳遞。如在普通使用中選擇/插入/更新/刪除無特權,並且在訪問升級頁面時還具有與定義/索引相關的內容的特權。
次佳解決方案
「所有權限」 通常意味着您應該向用户展示一切。但是…
我發現至少 one article 聲稱 MySQL 用户只需要:
- 選擇
- 插
- 更新
Digging deeper,我發現為了完全運行 (自動更新,plug-in 安裝/卸載等),WordPress 需要一些額外的權限:
- 刪除
- ALTER(更新)
- 創建表
- DROP TABLE
另外,沒有引用,但它是有道理的:
- 指數
但是,我認為只有兩個堅實的參考資料可以通過其他地方發表的意見予以支持。我仍然鼓勵您堅持使用 GRANT ALL,但如果您絕對必須限制您的數據庫使用,請從這 7 個特權開始,並完全測試,以確保事情按預期工作。
第三種解決方案
Codex 在限制數據庫用户權限方面必須説明的是:
For normal WordPress operations, such as posting blog posts, uploading media files, posting comments, creating new WordPress users and installing WordPress plugins, the MySQL database user only needs data read and data write privileges to the MySQL database; SELECT, INSERT, UPDATE and DELETE.
Therefore any other database structure and administration privileges, such as DROP, ALTER and GRANT can be revoked. By revoking such privileges you are also improving the containment policies.
Note: Some plugins, themes and major WordPress updates might require to make database structural changes, such as add new tables or change the schema. In such case, before installing the plugin or updating a software temporarily allow the database user the required privileges.
http://codex.wordpress.org/Hardening_WordPress
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。