1.创建新用户
创建用户bill,密码: bill123!@#chen
本地登录 :
MySQL -u root -p
CREATE USER 'bill'@'localhost' IDENTIFIED BY 'bill123!@#chen';



远程登录 :
mysql> CREATE USER 'sun'@'%' IDENTIFIED BY 'sun.chengdu9!';
Query OK, 0 rows affected (0.00 sec)


虽然创建了,但是访问该用户没有任何的数据库信息。这个时候,需要给用户授权。
2、为用户授权数据库的访问
授权格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by ‘密码’;
授权bill用户拥有testDB数据库的所有权限:
grant all privileges on testDB.* to “bill”@”localhost” identified by “bill123!@#chen”;
授权bill用户在本地拥有全部数据库的所有权限:
grant all privileges on *.* to “bill”@”localhost” identified by “bill123!@#chen”;


授权 sun 用户拥有远程访问数据库的权限、
grant all privileges on . to 'sun'@'%' identified by 'sun.chengdu9!';

