登录本地用户
mysql -u root -p1
登录外网用户(需要注意服务器可能只允许本地登录,需要修改响应的配置文件)
mysql -u zhrt -h 10.64.6.4 -p1
添加用户
1.允许本地访问的用户(127.0.0.1)
create user zhrt@localhost identified by '123456'; 1
2.允许外网IP访问的用户
create user 'zhrt'@'%' identified by '123456'; 1
用户分配权限
授予用户在本地服务器对该数据库的全部权限
grant all privileges on dbname.* to zhrt@localhost identified by '123456';1
授予用户通过外网IP对于该数据库的全部权限
grant all privileges on dbName.tableName to 'user'@'%'
grant all privileges on dbName.tableName to 'user'@'%' identified by 'Security132.' with grant option;
grant insert,select,update,delete on entertainment.* to 'user'@'%' identified by 'Security132.';
三、查看用户权限
mysql> show grants for 'yangxin'@'localhost';
四、回收权限删除yangxin这个用户的create权限,该用户将不能创建数据库和表。
mysql> revoke create on *.* from 'yangxin@localhost';mysql> flush privileges;
刷新权限
flush privileges;
评论区