I’m trying to connect my windows machine with xampp, using php with PDO, to a server on the local network (Linux)
<?php
$dbname = "DBNAME";
$user = "USERNAME";
$pass = "PASSWORD";
try{
$conn = new PDO("mysql:host=HOST;port=PORT;dbname=" . $dbname, $user, $pass);
echo "Conexão com o banco de dados realizada com sucesso";
} catch(PDOException $err) {
echo "Erro ao conectar ao banco: ". $err->getMessage();
}
?>
This gives me an error:
SQLSTATE[HY000] [2002] No connection could be made because the target machine was selected
How to solve the problem?
New contributor
Abelardo Alves is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.