登陸root或者管理員用戶
#test 數據庫用戶名
#testpassword 數據庫密碼
#創建允許遠程訪問的用戶 create user test@'%' identified by 'testpassword';
#執行成功之后刷新用戶權限
flush privileges;
執行
#admin_v6 為數據庫名稱 grant all privileges on admin_v6.* to "test"@"%" identified by "testpassword" with grant option;
#執行成功之后刷新用戶權限
flush privileges;
允許mysql用戶遠程訪問
注:只支持mysql 8.0之前的版本
grant all on *.* to test@'%' identified by '你的密碼' with grant option; flush privileges;
%表示允許任何ip地址
賬戶如果不存在的話會創建
mysql 8.0之后的版本
grant all privileges on *.* to test@'%' with grant option;
#使用navicat連接mysql 8.0 密碼加密規則問題,錯誤碼【1251】
ALTER USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY '你的密碼';

刪除用戶
drop user 'test'@'%';
查詢所有用戶
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;