mysql 绑定内网ip 允许指定ip访问 新增用户 授权 修改密码
1、新建用户
MySQL -u root -p
CREATE USER 'test'@'localhost' IDENTIFIED BY '1234'; #本地登录
CREATE USER 'test'@'%' IDENTIFIED BY '1234'; #远程登录
quit
mysql -u test -p #测试是否创建成功
2. 授权test用户拥有testDB数据库的所有权限
grant all privileges on testDB.* to “test”@”localhost” identified by “1234”;
flush privileges; #刷新系统权限表
3.指定部分权限给用户:
grant select,update on testDB.* to “test”@”localhost” identified by “1234”;
flush privileges; #刷新系统权限表
4.授权test用户拥有所有数据库的某些权限
grant select,delete,update,create,drop on . to test@”%” identified by “1234”; #”%” 表示对所有非本地主机授权,不包括localhost
flush privileges;
5.修改指定用户密码
update set authentication_string=password(“新密码”) where User=”test” and Host=”localhost”;
flush privileges;