查看mysql数据库中的所有用户:
mysql> SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
#将host设置为localhost表示只能本地连接mysql
update user set host='localhost' where user='root'; flush privileges; #刷新权限表,使配置生效
设置远程连接
update user set host='%' where user='root' and host='localhost'; flush privileges;