您的位置:首页 > 运维架构 > Linux

Linux下Mysql常见连接错误

2015-06-27 21:31 627 查看
遇到这些问题,网上很多解决方案,一搜就有。在这我简单总结下

第一个:ERROR 2003 (HY000): Can't connect to MySQL server on '172.29.*.*' (113)

无法连接,可能有几个原因:

1、防火墙,看下iptables

2、配置文件中绑定了ip,检查bind adderss (my.cnf)

3、配置文件中skip-networking

第二个:ERROR 1130 (HY000): Host '192.168.*.*' is not allowed to connect to this MySQL server

在远程连接时候出现,因为没有权限。

可以使用下面语句给予权限:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.*.*' IDENTIFIED BY '1234' WITH GRANT OPTION;


其中192.168.*.*是本地ip,root和1234是允许的登录名和密码,这么连接就安全多了。

如果不限制ip,用%表示所有。

第三个:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

是因为忘记密码了。。

最简单方式:/etc/mysql/my.cnf 或/etc/my.cnf

加入skip-grant-tables

重启mysql服务:service mysqld restart

可以直接进入:mysql -u root

执行改密码:update user set password('password') where user = 'root';

把my.cnf中的skip-grant-tables去掉,重启服务
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: