简体   繁体   中英

PDOException SQLSTATE[HY000] [2002] Connection timed out on my local computer

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

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)

My code : $dbh = new PDO("mysql:host={$db_host};dbname={$db_name}", $db_user, $db_pass);

My remote server is from LWS.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM