1、创建用户
./mysql -u root -p
#创建一个本地访问的用户
create user 'xaweb'@'localhost' identified by '123456';
#创建一个远程访问的用户
create user 'xaweb'%'localhost' identified by '123456';
2、分配权限
#授予用户在本地服务器对该数据库的全部权限
grant all privileges on dbname.* to 'xaweb'@'localhost' identified by '123456';
#授予用户通过外网IP对该数据库的全部权限
grant all privileges on dbname.* to 'xaweb'@'%' identified by '123456';
#刷新配置
flush privileges;