如何解決linuxphp連接mysql權(quán)限不夠問題

這篇文章主要介紹“如何解決linux php連接MySQL權(quán)限不夠問題”,在日常操作中,相信很多人在如何解決linux php連接mysql權(quán)限不夠問題問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”如何解決linux php連接mysql權(quán)限不夠問題”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!

十年的郊區(qū)網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。營(yíng)銷型網(wǎng)站建設(shè)的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整郊區(qū)建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“郊區(qū)網(wǎng)站設(shè)計(jì)”,“郊區(qū)網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

linux php連接mysql權(quán)限不夠的解決辦法:1、通過(guò)使用grant命令給普通數(shù)據(jù)用戶授予查詢,插入等權(quán)限;2、通過(guò)grant給數(shù)據(jù)庫(kù)開發(fā)人員授予創(chuàng)建表和索引等權(quán)限即可。

如何解決linux php連接mysql權(quán)限不夠問題

本文操作環(huán)境:linux5.9.8系統(tǒng)、PHP7.1版、DELL G3電腦

linux php連接mysql權(quán)限不夠怎么辦?

linux php連接mysql權(quán)限不夠,mysql精細(xì)權(quán)限劃分:

mysql中可以給你一個(gè)用戶授予如select,insert,update,delete等其中的一個(gè)或者多個(gè)權(quán)限,主要使用grant命令,用法格式為:

grant 權(quán)限 on 數(shù)據(jù)庫(kù)對(duì)象 to 用戶

一、grant 普通數(shù)據(jù)用戶,查詢、插入、更新、刪除 數(shù)據(jù)庫(kù)中所有表數(shù)據(jù)的權(quán)利

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 命令來(lái)替代:

grant select, insert, update, delete on testdb.* to common_user@’%’

二、grant 數(shù)據(jù)庫(kù)開發(fā)人員,創(chuàng)建表、索引、視圖、存儲(chǔ)過(guò)程、函數(shù)。。。等權(quán)限

grant 創(chuàng)建、修改、刪除 mysql 數(shù)據(jù)表結(jié)構(gòu)權(quán)限。
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 外鍵權(quán)限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 臨時(shí)表權(quán)限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 索引權(quán)限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 視圖、查看視圖源代碼 權(quán)限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show view on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 存儲(chǔ)過(guò)程、函數(shù) 權(quán)限。
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 管理某個(gè) mysql 數(shù)據(jù)庫(kù)的權(quán)限

grant all privileges on testdb to dba@’localhost’

其中,關(guān)鍵字 “privileges” 可以省略。

四、grant 高級(jí) dba 管理 mysql 中所有數(shù)據(jù)庫(kù)的權(quán)限

grant all on *.* to dba@’localhost’

五、mysql grant 權(quán)限,分別可以作用在多個(gè)層次上

1. grant 作用在整個(gè) mysql 服務(wù)器上:

grant select on *.* to dba@localhost; - dba 可以查詢 mysql 中所有數(shù)據(jù)庫(kù)中的表。
grant all on *.* to dba@localhost; - dba 可以管理 mysql 中的所有數(shù)據(jù)庫(kù)

2. grant 作用在單個(gè)數(shù)據(jù)庫(kù)上:

grant select on testdb.* to dba@localhost; - dba 可以查詢 testdb 中的表。

3. grant 作用在單個(gè)數(shù)據(jù)表上:

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 作用在存儲(chǔ)過(guò)程、函數(shù)上:

grant execute on procedure testdb.pr_add to ’dba’@’localhost’
grant execute on function testdb.fn_add to ’dba’@’localhost’

六、查看 mysql 用戶權(quán)限

查看當(dāng)前用戶(自己)權(quán)限:

show grants;

查看其他 mysql 用戶權(quán)限:

show grants for dba@localhost;

七、撤銷已經(jīng)賦予給 mysql 用戶權(quán)限的權(quán)限

revoke 跟 grant 的語(yǔ)法差不多,只需要把關(guān)鍵字 “to” 換成 “from” 即可:

grant all on *.* to dba@localhost;
revoke all on *.* from dba@localhost;

八、mysql grant、revoke 用戶權(quán)限注意事項(xiàng)

1. grant, revoke 用戶權(quán)限后,該用戶只有重新連接 mysql 數(shù)據(jù)庫(kù),權(quán)限才能生效。

2. 如果想讓授權(quán)的用戶,也可以將這些權(quán)限 grant 給其他用戶,需要選項(xiàng) “grant option“

grant select on testdb.* to dba@localhost with grant option;

這個(gè)特性一般用不到。實(shí)際中,數(shù)據(jù)庫(kù)權(quán)限最好由 dba 來(lái)統(tǒng)一管理。

注意:修改完權(quán)限以后 一定要刷新服務(wù),或者重啟服務(wù)

到此,關(guān)于“如何解決linux php連接mysql權(quán)限不夠問題”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!

網(wǎng)站欄目:如何解決linuxphp連接mysql權(quán)限不夠問題
標(biāo)題路徑:http://bm7419.com/article36/igodpg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司電子商務(wù)、關(guān)鍵詞優(yōu)化、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站排名、軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司