windows mysql8.0创建用户和授权

1.创建用户
create user ‘username’@‘localhost’ identified by ‘password’;
示例:create user ‘guocheng’@‘192.168.1.24’ identified by ‘guocheng’;
guocheng:第一个账号名称,第二个位密码
192.168.1.24:只能这个ip访问guocheng账号

2.授权数据库
grant all privileges on database_name.* to ‘username’@‘localhost’;
示例:grant all privileges on test.* to ‘guocheng’@‘192.168.1.24’ with grant option;
test:授权test库的所有权限
guocheng:账号
192.168.1.24:ip

3.刷新权限
flush privileges;

你可能感兴趣的:(mysql)