windows环境下,可以在图形界面下配置,配置程序在"MySQL\MySQL Server 5.5\bin\MySQLInstanceConfig.exe"
运行MySQLInstanceConfig.exe后,不勾选“Enable root access from remote machines”,即可实现禁用root用户远程访问MySQL的功能
同理勾选则可完成root用户可以远程访问的功能。
配置后影响的文件是:MySQL\MySQL Server 5.5\data\mysql中的user.MYI和user.MYD
或者直接用SQL语句对MySQL中的mysql库下的user表,将该表中的HOST字段中值为"%"更新为其它值,并重启服务端即可
例如:
update user set host = 'local' where host = '%'; //首选
delete from user where host = '%'; //不推荐,想再恢复远程会造成麻烦