【建站學(xué)院文檔】今天在分離web和DB的過程中,遇到了mysql權(quán)限的問題。
在mysql中執(zhí)行
use mysql;
select user,password,host from user;
有一個不需要用戶名和密碼就可以登錄的帳號。于是就改掉這個
update user set user=’root’,host=’192.168.0.%’ where user=” and host=’localhost’;
修改用戶權(quán)限
grant all on * to root@192.168.0.%;
flush privileges;
從本地連接測試還是只有test表,而且沒有建數(shù)據(jù)庫的權(quán)限。通過以下命令查詢
show grants root@192.168.0.%;
發(fā)現(xiàn)如下結(jié)果
GRANT USAGE ON *.* TO ‘root’@'192.168.0.%’
這樣的結(jié)果明顯不對嘛。
退出,以另一ROOT用戶登錄,執(zhí)行如下命令。
show grants for current_user();
結(jié)果如下:
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'localhost’ WITH GRANT OPTION
你發(fā)現(xiàn)沒有,原來后面還需要加上with grant option的,歡迎您繼續(xù)在建站學(xué)院交流!~