查詢mysql具體版本
SELECT @@VERSION
問題分析:mysql版本8.0.13,在給新用戶授權時,發生了變化:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'password' with grant option' at line 5, Time: 0.000000s
出錯的語句:
grant all privileges on *.* to 'root'@'172.16.10.203' identified by 'password' with grant option
修正后的語句:分開三次執行
#創建賬戶
create user 'root'@'172.16.10.203' identified by 'password'
#賦予權限,with grant option這個選項表示該用戶可以將自己擁有的權限授權給別人
grant all privileges on *.* to 'root'@'172.16.10.203' with grant option
#改密碼&授權超用戶,flush privileges 命令本質上的作用是將當前user和privilige表中的用戶信息/權限設置從mysql庫(MySQL數據庫的內置庫)中提取到內存里
flush privileges;
原因分析 :此版的的mysql版本把將創建賬戶和賦予權限分開了。
創建賬戶::create user ‘用戶名’@‘訪問主機’ identified by ‘密碼’;
賦予權限:grant 權限列表 on 數據庫 to ‘用戶名’@‘訪問主機’ ;
with grant option這個選項表示該用戶可以將自己擁有的權限授權給別人
