Not able to Connect to MYSQL Server

Hi,

I am not able to connect to MYSQL, I getting the following error message,

Warning : mysqli::__construct(): (HY000/2002): Connection timed out in /home/vol7_1/epizy.com/epiz_26329463/htdocs/app/database.php on line 9
Connection failed: Connection timed out

Please let me know, how to get around this problem.

Username: epiz_26329463
Sincerely,
Vimal

The reason is…

Hi,
Thanks for the reply, I did not connect to MYSQL from outside the Hosting Account nor from Any App. I have the PHP script uploaded to the free hosting account only, still I am not able to connect to MYSQL even if I open it in a web browser. There is some problem from the Server Hosting Side.
Sincerely,
Vimal

Can you share the code? Make sure to blur/hide the credentials or any sensitive info! Also can you share the domain name?

Hi,
Domain name: www.vimaltech.rf.gd

$servername = “localhost”;
$username = “username”;
$password = “password”;
$database=“database-name”

$connection = new mysqli($servername, $username, $password, $database);

if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}
echo “Connected successfully”;
Sincerely,
Vimal

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn= mysqli_connect($servername,$username,$password,$dbname);
// Check connection
if (!$conn) {
  die("Connection failed: " . mysqli_connect_error());
}
echo "Connected Successfully.";
?>

You forgot the ; after $database="database-name". Also is this a new site?

Hi,

You forgot the ; after $database="database-name"- that just by mistake even after adding the ; after database name it is showing the same error. The site is 2 years old.

Please let me know if there is something wrong in using new mysqli in PHP 7
$connection = new mysqli($servername, $username, $password, $database);
Sincerely,
Vimal

On line 7: $connection = new mysqli($servername, $username, $password, $database); I think $database should be $dbname?

Hi,
Nope, changed and checked with $dbname still getting the same error, I think there is some problem with the server side, because from the script side everything is correct and I am able to connect to MYSQL from a different hoster.
Sincerely,
Vimal

Yes it can be though.

Please make sure your using the details found in the client area. @jaikrishna.t , I believe the variables can have whatever names you want, as long as they are in the correct order.

1 Like

@Airpalace, this has to be a credentials issue. Please make sure to type them correctly. They are case sensitive.

No it does not. In fact, I think there may be an issue with the server.

1 Like

Yes I too have the same feeling of an outage @Greenreader9!

1 Like

Than why did you say this?

That was before I saw your post on another topic but the same issue like this one:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.