當時的場景是這樣的:
在剛裝好資料庫時,因為考慮到安全的問題,我在第一次登入資料庫時就刪除了那些自帶的root使用者,也就是沒有密碼的,host為localhost | 主機名 | 127.0.0.1這些root使用者,還有空使用者名稱的。
然後我就自己建立了乙個root使用者,命令如下:
mysql > grant all on *.* to root@'%' identified by '123123';
這許可權夠大吧!
但是當我退出後,使用此使用者登入mysql -uroot -h192.168.0.177 -p123123
進來時使用這個root使用者建立使用者,出現如下報錯:
許可權拒絕!!!mysql> grant all on wordpress1.* to wordpress@'192.168.0.%' identified by '123123';
error 1044 (42000): access denied for user 'root'@'192.168.0.%' to database 'wordpress1'
後來在網上各種找答案,花了好長時間,終於解決了
原來是自己建立的root使用者沒有建立使用者的許可權!with grant option
後來檢視了user表。修改了這個值,步驟如下:
許可權為n,也就是此使用者沒有建立使用者的許可權,將其修改mysql> select user,host,grant_priv from mysql.user;
+-----------+-------------+------------+
| user | host | grant_priv |
+-----------+-------------+------------+
| root | 192.168.0.% | n |
+-----------+-------------+------------+
1 rows in set (0.00 sec)
mysql> update mysql.user set grant_priv='y' where user='root';
再次檢視
然後,也是必須的一步:mysql> select user,host,grant_priv from mysql.user;
+-----------+-------------+------------+
| user | host | grant_priv |
+-----------+-------------+------------+
| root | 192.168.0.% | y |
+-----------+-------------+------------+
1 rows in set (0.00 sec)
mysql> flush privileges;
千萬要記得,我就是沒寫!哈哈哈
檢視的結果是這樣的:
後面出現mysql> show grants for root@'192.168.0.%'\g
*************************** 1. row ***************************
grants for root@192.168.0.%: grant all privileges on *.* to 'root'@'192.168.0.%' identified by password '*e56a114692fe0de073f9a1dd68a00eeb9703f3f1' with grant option
1 row in set (0.00 sec)
with grant option
就可以了!
執行完flush privileges;
後預設還是不能建立使用者,需要退出一下,再次登入,然後建立就ok了!!!
mysql> grant all on wordpress1.* to wordpress@'192.168.0.%' identified by '123123';
query ok, 0 rows affected (0.00 sec)
MySQL的root使用者
mysql的root使用者 摘要 mysql的root使用者十分重要,它全面控制mysql的執行與設定,本文主要介紹mysql中root的遠端登入設定以及密碼的設定和修改。關鍵字 mysql root 目錄 一 mysql遠端登入設定 二 mysql中root使用者 主要內容 一 mysql遠端登入...
root使用者不能修改iptable檔案
問題 需要放通ip 埠 執行 vi etc sysconfig iptables,新增完成後,wq儲存,提示檔案唯讀無法儲存!解決步驟 1.檢視檔案許可權 ls ld etc sysconfig iptables 2.檢視檔案屬性 lsattr iptables,顯示 i iptables 意思是檔...
Mysql忘記root使用者
修改口令必須要連線伺服器才能修改口令,如果不知道root口令,就只能先強行關停伺服器,然後在不適用許可權表驗證的請款下重新啟動伺服器。一 關停伺服器 如果是在linux系統下 以系統的root使用者登陸,進入終端 殺掉mysql程序 方法1 killall mysqld 方法2 ps aux 檢視所...