您的位置:首页 > 数据库 > MySQL

解决"ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.247.128' (111)"

2015-01-25 19:03 363 查看
1.问题描述

在连接数据库时出现连接失败信息:

xx@ubuntu:~$mysql-h192.168.247.128-uroot-p123456 mysql:[Warning]Usingapasswordonthecommandlineinterfacecanbeinsecure. ERROR2003(HY000):Can'tconnecttoMySQLserveron'192.168.247.128'(111) xx@ubuntu:~$
2.解决方法

出现上面mysql数据库连接失败的原因是多种的,其中可用pingip来看看网络是否畅通,下面是本人的解决方法。

这是因为之前我进行了root密码设置操作,

root@ubuntu:/usr/local/mysql/bin#./mysqld_safe--user=mysql--skip-grant-tables--skip-networking& [1]5810
注意上面的--skip-grant-tables--skip-networking,只允许本地socket连接,放弃对TCP/IP的监听

在解决上述问题之前,我们先保证已经对mysql数据库进行远程授权,

进入/usr/local/mysql/support-files/下,执行以下命令:

#cpmy-default.cnfmy.cnf
这里得到了mysql数据库的配置文件my.cnf,再重启mysql服务,然后执行mysql-h192.168.247.128-uroot-p(ps:主机ip请输入自己的)

并输入数据库用户root的密码即可连接mysql数据库。如下:

xx@ubuntu:/usr/local/mysql$sudo./support-files/mysql.serverrestart [sudo]passwordforxx: ShuttingdownMySQL ....* StartingMySQL ..* xx@ubuntu:/usr/local/mysql$mysql-h192.168.245.128-uroot-p Enterpassword: WelcometotheMySQLmonitor.Commandsendwith;or\g. YourMySQLconnectionidis1 Serverversion:5.7.5-m15MySQLCommunityServer(GPL) Copyright(c)2000,2014,Oracleand/oritsaffiliates.Allrightsreserved. OracleisaregisteredtrademarkofOracleCorporationand/orits affiliates.Othernamesmaybetrademarksoftheirrespective owners. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement. mysql>




OK,Enjoyit!!!





                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐