PDOException SQLSTATE [HY000] [2002]我的本地计算机上的连接超时 [英] PDOException SQLSTATE[HY000] [2002] Connection timed out on my local computer

查看:702
本文介绍了PDOException SQLSTATE [HY000] [2002]我的本地计算机上的连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我已经从服务器导入了我的代码,但是本地代码无法连接到远程mysql数据库.

Recently I've imported my code from my server but the local code can't connect to the remote mysql database.

所以我有2个问题: -我可以访问我的远程数据库吗 如果是,为什么我的代码不起作用? 如果否:是否有办法绕过此问题? (我不想复制将在本地计算机上运行的mysql数据库)

So I have 2 questions : - Can I access to my remote databse If yes : why is my code not working ? If no : is there a way to bypass this problem ? (I don't want to make a copy of my mysql database that would run on my local computer)

我的代码: $dbh = new PDO("mysql:host={$db_host};dbname={$db_name}", $db_user, $db_pass);

我的远程服务器来自LWS.

My remote server is from LWS.

推荐答案

对于远程访问,您应该启用对MySQL Server的远程访问.
http://www .cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

For remote access, You should to enable remote access to your MySQL Server.
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

这篇关于PDOException SQLSTATE [HY000] [2002]我的本地计算机上的连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆