這條語句適用於MySQL8.0之前的
而MySQL8.0及之后的,設置遠程連接權限要用下面的語句才可以
create user root@'%' identified by '123456';
grant all privileges on *.* to root@'%' with grant option;
1、創建用戶
CREATE USER '用戶名'@'host' IDENTIFIED BY '密碼';
2.授權(全部數據庫權限)
grant all privileges on *.* to '用戶名'@'%' ;
3.刷新權限
flush privileges;