1.查看当前用户
select current_user;
current_user |
---|
root@localhost |
2.使用当前用户
use mysql;
select user,host from user;
user | host |
---|
mysql.infoschema | localhost |
mysql.session | localhost |
mysql.sys | localhost |
root | localhost |
3.创建当前MySQL账号
create user 'aaaa'@'192.128.1.%' identified by 'afafaf123456';
ALTER USER 'aaaa'@'192.128.1.%' IDENTIFIED BY 'afafaf123456';
flush privileges;
select host,user from user;
user | host |
---|
mysql.infoschema | localhost |
mysql.session | localhost |
mysql.sys | localhost |
root | localhost |
aaaa | 192.128.1.% |
4.授权用户可以访问的表
grant all privileges on test.* to 'aaaa'@'192.128.1.%';