My DataBase host and my website host are not the same.
I have created a few web apps on .NET with a web.config or app.config file where I could easily set a machinekey for the mysql connection on a mysql database for the web-farm.
This was very simple on .NET or Visual studio web app.
<system.web>
<machineKey validationKey="C250127840E44F50A34824E348FC089A0DE6C60C3D0CF61A31AB01BCAB6AE3940C82648D2F085B1DECFA5204AD393A5810403DABED73002608AEF7231F29E6CB" decryptionKey="8A86EB63181EDD9439D664ACA990D07302F3280E6F6919B3" validation="SHA1" decryption="AES"/>
</system.web>
However
I am now creating a website for a Linux host. I am using the same Database and again, on testing, the connection is fine. However, when published, the mysql connection is refused.
I have a suspision that it is again because of the web-farm, but there is no evidence of it.
I have allowed the host IP on remote-mysql.
I have checked that the Host IP is not blocked on the Mysql host.
I have checked the ports for the mysql connection.(it works before publish).
I have checked the user privileges on the mysql username.
I have also mailed the support guys on my mysql host to see if there is anything on their side.
I have been sitting with this for a while, and its frustrating.
Is there a way i can set the Machine key on this app/is it needed?
If anyone suggest anything else I could check, or point me to a setting I may be missing, that would be MUCH appreciated.
Below is my connection, which DOES work when I run the application.
Publish to host, Connection refused.
<?php
$host = "server IP";
$port = 3306;
$user = "username";
$password = "**********";
$dbname = "mysql.table";
$conn = new mysqli($host, $user, $password, $dbname, $port);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
<?php
$host = 'DB_IP';
$dbname = 'DB_Name';
$dsn = 'mysql:host=DB_IP;dbname=DB_Name';
$username = 'Username';
$password = 'Password';
try {
$conn = new PDO($dsn, $username, $password);
echo "Connected to $dbname at $host successfully.";
} catch (PDOException $pe) {
die("Could not connect to the database $dbname :" . $pe->getMessage());
}
?>
This is when i test the code ::
Connected to mydb at IPADDRESS successfully.
This is after publish to the host ::
Could not connect to the database mydb :SQLSTATE[HY000] [2002] Connection refused
I am getting the same result with PDO and MySqli
If anyone can please assist. I have been looking for answers for days now.
Thanks so much for all the assistance. It seems that the host I was using for my database for almost 4 years has decided to lock down the 3306 access to workbench and remote access. No notification of this.
They have decided that the attack rate on the MySQL is too high. Now only local host and same host websites work there. This is strange though, because all my other projects and workbench still connect. I have argued this with them, but they insist.
I will have to move the database elsewhere.
I did a test this morning on a different host. All worked perfectly.
Thanks again for all the assistance.