mysql添加只读账号,virtualBox添加端口映射
用root用户进入mysql
mysql -uroot -p use mysql CREATE USER ‘test’@’localhost’ IDENTIFIED BY ‘testmm' grant select on *.* to test@"localhost" Identified by "testmm";
添加端口转发
点击设置弹出
添加端口转发,访问1022端口就是访问虚拟机22端口
附加其它sql
CREATE USER ‘test’@’localhost’ IDENTIFIED BY ‘testmm' grant select on *.* to 'test'@'%' with grant option; //有些版本'%'不包括localhost,要单独对@'localhost'进行赋值 grant select on *.* to test@"localhost" Identified by "testmm"; //刷新配置 flush privileges; //修改root密码 update mysql.user set authentication_string='新密码' where user='root'; use mysql //查询权限 select * from user where user='test'; //修改 update user set Select_pri='Y' where user='test' //添加全部权限 grant select,insert,update,delete on *.* to test@"localhost" Identified by "testpassword";