EDIT : [SOLVED]
Problem solved. I finally found an issue. There were some errors. First I tried to connect with an IP when my file was in my FTP. To connect to my mysql I had to write the db_host by localhost, not by the IP. Secondly, there were few problems with databases permissions, i was only able to create a database entitled test, idk why... SO if I enter db_name as "test", all works fine. It's so weird!
I have some problems to access to mysql when I run my install.php within a FTP. Let me explain : my install.php is supposed to created a database when the user is installing his website. All works fine is I run my install.php in local unlike with a FTP server.
Let me add that i'm 100% sure that my access are correct (I mean the host, the username and password). Otherwise this process didn't work in local (?).
Error code :
DB ERROR: SQLSTATE[28000] [1045] Access denied for user 'alpha'@'my_host' (using password: YES)
My install.php file :
<?php
if (empty($_POST['db_host']) OR empty($_POST['db_name']) OR empty($_POST['db_username']) OR empty($_POST['db_password']))
{ ?>
<?php include("content/head.php"); ?>
<div class="container install-container text-center">
<div class="install-container-border">
<h1 class="exo-bold">
<a><img src="/../img/alpha-logo-small.png"></a></br>
<small class="hvr-shadow-radial">Installation</small></br></br>
<div style="padding-right: 100px; padding-left: 100px">
<div class="install-progress">
<div class="install-progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 50%;">50%</div>
</div>
</div>
</h1>
<div class="text-left" style="padding-left: 150px">
<form method="post" action="install.php" style="font-family: raleway !important;">
<p>
<div style="height: 30px">Database Host: <input type="text" name="db_host" style="height: 22px"/></div>
<?php if (!empty($_POST['try']) && empty($_POST['db_host'])) {;?> <div class="alert-install alert-danger" role="alert">Database host is required.</div> <?php } ?>
<div style="height: 30px">Database Name: <input type="text" name="db_name" style="height: 22px"/></div>
<?php if (!empty($_POST['try']) && empty($_POST['db_name'])) {;?> <div class="alert-install alert-danger" role="alert">Database name is required.</div> <?php } ?>
<div style="height: 30px">Database Username: <input type="text" name="db_username" style="height: 22px"/></div>
<?php if (!empty($_POST['try']) && empty($_POST['db_username'])) {;?> <div class="alert-install alert-danger" role="alert">Database username is required.</div> <?php } ?>
<div style="height: 30px">Database Password: <input type="password" name="db_password" style="height: 22px"/></br></div>
<?php if (!empty($_POST['try']) && empty($_POST['db_password'])) {;?> <div class="alert-install alert-danger" role="alert">Database password is required.</div> <?php } ?>
<div style="height: 30px">Admin Username: <input type="text" name="adm_username" style="height: 22px"/></div>
<?php if (!empty($_POST['try']) && empty($_POST['admin_username'])) {;?> <div class="alert-install alert-danger" role="alert">Admin username is required.</div> <?php } ?>
<div style="height: 30px">Admin Password: <input type="password" name="adm_password" style="height: 22px"/></br></div>
<?php if (!empty($_POST['try']) && empty($_POST['admin_password'])) {;?>
<div class="alert-install alert-danger" role="alert">Admin password is required.</div> <?php } ?>
<input type="hidden" name="try" value="try"/>
<div style="height: 50px; margin-top: 50px;">
<input type="submit" value="Confirm"style="font-family: raleway !important;"class="btn btn-default btn-alpha text-center"/>
</div>
</p>
</form></br></br>
</div>
</div>
</div>
<?php }
else
{
$dbh = new PDO("mysql:host=".$_POST['db_host'], $_POST['db_username'], $_POST['db_password']);
$dbh->exec("CREATE DATABASE ".$_POST['db_name'].";");
$dbh->exec("USE ".$_POST['db_name'].";");
$dbh->exec("CREATE TABLE admin (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, username VARCHAR(255) UNIQUE, password VARCHAR(255));");
$dbh->exec("INSERT INTO admin (username, password) VALUES ('".$_POST['adm_username']."','".$_POST['adm_password']."');");
echo "BDD created!";
}
?>
I successfully tried to access my BDD within a terminal with : mysql -h my_host -u alpha -p
Your issue is related to the access itself. Please check the credentials on the remote server. Your script may be running on local as the provided credentials may be correct for your local environment.