【IT168 服务器学院】刚安装完的MySQL中只有一个默认的用户,这就是root@localhost,如果需要使数据库被更多的用户访问使用,就需要添加新用户, 在windows可以用下面两种方法来添加:
使用GRANT语句:
grant select on test.* to ''yonghu''@''%'' identified by ''some_pass'' with grant option;
例子表示增加一 个用户,名称是yonghu,来自任何位置,密码是some_pass可以对test数据库的任何表进行select命令。
直接向grant表中插入用户:
shell>mysql --user=root mysql
mysql>insert into user (Host,User,Password) values(''localhost'',''shagua'','''');
mysql>flush privileges;表示将来自本机的用户,名叫shagua,密码为空,添加入数据库。