Mysql Workbench 连接Ubuntu上的Mysql时报如下错误:
原因:查看 /etc/mysql/mysql.conf.d/mysqld.cnf
# # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1
默认只支持本地访问。
修改为:
# # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 0.0.0.0
然后重启Mysql :
service mysql restart
再重新连接报如下错误:
查找原因:
显示只能localhost 访问。
解决方法:修改授权远程访问
修改:
mysql> update user set host="%" where user="root";
或新增:
grant all privileges on *.* to 'root'@'%' identified by 'admin123' with grant option; flush privileges;
%代表通配,也可换成IP地址。