mysql -u root -p
添加新用户
允许本地 IP 访问 localhost, 127.0.0.1
create user 'wfee'@'localhost' identified by 'wfee';
允许外网 IP 访问
create user 'wfee'@'%' identified by 'wfee';
刷新授权
flush privileges;
为用户创建数据库
create database wfee DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
为新用户分配权限
授予用户通过外网IP对于该数据库的全部权限
grant all privileges on wfee
.* to 'wfee'@'%' identified by 'wfee';
grant all privileges on wfee
.* to 'wfee'@'%' identified by 'wfee';
GRANT ALL PRIVILEGES ON . TO 'wfee'@'%' WITH GRANT OPTION;
grant all privileges on . to 'wfee'@'%' identified by 'wfee';
刷新权限
flush privileges;
退出 root 重新登录
exit
用新帐号 test 重新登录,由于使用的是 % 任意IP连接,所以需要指定外部访问IP
mysql -u test -h 115.28.203.224 -p
网友评论