linux php連接mysql權限不夠的解決方法:1、透過使用grant指令給予一般資料使用者查詢,插入等權限;2、透過grant給資料庫開發人員授予建立資料表和索引等權限即可。
本文操作環境:linux5.9.8系統、PHP7.1版、DELL G3電腦
#linux php連線mysql權限不夠怎麼辦?
linux php連接mysql權限不夠,mysql精細權限劃分:
mysql中可以給你一個用戶授予如select,insert,update,delete等其中的一個或多個權限,主要使用grant指令,用法格式為:
grant 权限 on 数据库对象 to 用户
一、grant 普通資料用戶,查詢、插入、更新、刪除資料庫中所有表格資料的權利
grant select on testdb.* to common_user@’%’ grant insert on testdb.* to common_user@’%’ grant update on testdb.* to common_user@’%’ grant delete on testdb.* to common_user@’%’
或者,用一條mysql 指令來取代:
grant select, insert, update, delete on testdb.* to common_user@’%’
二、grant 資料庫開發人員,建立表格、索引、檢視、預存程序、函數。 。 。等權限
grant 创建、修改、删除 mysql 数据表结构权限。 grant create on testdb.* to developer@’192.168.0.%’; grant alter on testdb.* to developer@’192.168.0.%’; grant drop on testdb.* to developer@’192.168.0.%’; grant 操作 mysql 外键权限。 grant references on testdb.* to developer@’192.168.0.%’; grant 操作 mysql 临时表权限。 grant create temporary tables on testdb.* to developer@’192.168.0.%’; grant 操作 mysql 索引权限。 grant index on testdb.* to developer@’192.168.0.%’; grant 操作 mysql 视图、查看视图源代码 权限。 grant create view on testdb.* to developer@’192.168.0.%’; grant show view on testdb.* to developer@’192.168.0.%’; grant 操作 mysql 存储过程、函数 权限。 grant create routine on testdb.* to developer@’192.168.0.%’; - now, can show procedure status grant alter routine on testdb.* to developer@’192.168.0.%’; - now, you can drop a procedure grant execute on testdb.* to developer@’192.168.0.%’;
三、grant 普通 dba 管理某個 mysql 資料庫的權限
grant all privileges on testdb to dba@’localhost’
其中,關鍵字 “privileges” 可以省略。
四、grant 高級dba 管理mysql 中所有資料庫的權限
grant all on *.* to dba@’localhost’
五、mysql grant 權限,分別可以作用在多個層次上
1. grant 作用在整個mysql 伺服器上:
grant select on *.* to dba@localhost; - dba 可以查询 mysql 中所有数据库中的表。 grant all on *.* to dba@localhost; - dba 可以管理 mysql 中的所有数据库
2. grant 作用在單一資料庫上:
grant select on testdb.* to dba@localhost; - dba 可以查询 testdb 中的表。
3. grant 作用在單一資料表上:
grant select, insert, update, delete on testdb.orders to dba@localhost;
4. grant 作用在表中的列上:
grant select(id, se, rank) on testdb.apache_log to dba@localhost;
5. grant 作用在預存程序、函數上:
grant execute on procedure testdb.pr_add to ’dba’@’localhost’ grant execute on function testdb.fn_add to ’dba’@’localhost’
六、查看mysql 使用者權限
查看目前使用者(自己)權限:
show grants;
查看其他mysql 使用者權限:
show grants for dba@localhost;
七、撤銷已經賦予給mysql 使用者權限的權限
revoke 跟grant 的語法差不多,只要把關鍵字「to」 換成「from」即可:
grant all on *.* to dba@localhost; revoke all on *.* from dba@localhost;
八、mysql grant、revoke 使用者權限注意事項
1. grant, revoke 使用者權限後,該使用者只有重新連接mysql 資料庫,權限才能生效。
2. 如果想要授權的用戶,也可以將這些權限 grant 給其他用戶,需要選項 「grant option「
grant select on testdb.* to dba@localhost with grant option;
這個特性一般用不到。實際上中,資料庫權限最好由 dba 來統一管理。
注意:修改完權限以後 一定要刷新服務,或重新啟動服務
推薦學習:《PHP影片教學》
以上是linux php連線mysql權限不夠怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本文比較了酸和基本數據庫模型,詳細介紹了它們的特徵和適當的用例。酸優先確定數據完整性和一致性,適合財務和電子商務應用程序,而基礎則側重於可用性和

本文討論了確保PHP文件上傳的確保,以防止諸如代碼注入之類的漏洞。它專注於文件類型驗證,安全存儲和錯誤處理以增強應用程序安全性。

本文討論了在PHP中實施API速率限制的策略,包括諸如令牌桶和漏水桶等算法,以及使用Symfony/Rate-limimiter之類的庫。它還涵蓋監視,動態調整速率限制和手

本文討論了使用password_hash和pyspasswify在PHP中使用密碼的好處。主要論點是,這些功能通過自動鹽,強大的哈希算法和SECH來增強密碼保護

本文討論了OWASP在PHP和緩解策略中的十大漏洞。關鍵問題包括注射,驗證損壞和XSS,並提供用於監視和保護PHP應用程序的推薦工具。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

Atom編輯器mac版下載
最受歡迎的的開源編輯器

Dreamweaver CS6
視覺化網頁開發工具

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。