My PHP code to connect with mysql was working till yesterday. Today its showing exception “Uncaught PDOException: SQLSTATE[HY000] [2002] Connection refused”.
I am able to log in to PhpMyAdmin using same credentials. But not able to connect through PHP.
This is the code I used
$serverName = 'localhost';
$dbName = 'dbname';
$user = "username";
$password = 'password';
$conn = new PDO("mysql:host=$serverName;dbname=$dbName", $user, $password);