登陆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;