解決mysql的賦權操作之GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION問題

一種情況

mysql的賦權操作:GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;

mysql賦權操作:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

flush privileges;
GRANT:賦權命令
ALL PRIVILEGES:當前用戶的所有權限
ON:介詞
*.*:當前用戶對所有數據庫和表的相應操作權限
TO:介詞
‘root’@’%’:權限賦給root用戶,所有ip都能連接
IDENTIFIED BY ‘123456’:連接時輸入密碼,密碼為123456
WITH GRANT OPTION:允許級聯賦權

20200901:
將GRANT語句通過代碼塊包起來

二種情況

mysql中遠程連接權限語句grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘ with grant optio報錯

grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘123456‘ with grant optio

原因: mysql的版本問題,這條語句適用於MySQL8.0之前

解決: mysql8.0及以上版本需要使用以下語句:

create user root@'%' identified by '123456';
grant all privileges on *.* to root@'%' with grant option;

到此這篇關於mysql的賦權操作:GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;的文章就介紹到這瞭,更多相關mysql的賦權操作:GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: