这是因为当前用户没有访问mysql的权限导致的在mysql中执行:grant all privileges on *.* to root@'%' identified by 'root'; 就可以访问了。