登陸MySQLmysql
mysql -u root -p
容許本地 IP 訪問 localhost, 127.0.0.1sql
create user 'test'@'localhost' identified by '123456';
容許外網 IP 訪問數據庫
create user 'test'@'%' identified by '123456';
刷新受權服務器
flush privileges;
create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
授予用戶經過外網IP對於該數據庫的所有權限ide
grant all privileges on `testdb`.* to 'test'@'%' identified by '123456';
授予用戶在本地服務器對該數據庫的所有權限code
grant all privileges on `testdb`.* to 'test'@'localhost' identified by '123456';
刷新權限ci
flush privileges;