We use 2 servers on CentOS. One with the PHP Code and the other with our database (MariaDB). We tried to connect them, but doesn't work in PHP and work with CLI Mysql, with the same credential. We created a special user to connect. We use a custom framework to connect to the database.
Everything work when we are on local (on a physical machine, not on server)
PHP version : 5.4.16
We tried a phpinfo(); : Mysql and Mysqli is activated. Connection to the MySQL serveur with CLI work.
define('DBNAME', 'start-up');
define('DBHOST', '10.13.200.13');
define('DBUSER', 'gestions');
define('DBPASSWORD', 'gestionPass');
From the custom framework :
protected static $db = false;
private static $last;
private static $prep;
//La dernière requete effectuée
private static $error = null;
private static $user;
private static $password;
private static $name;
private static $host;
public function __construct()
{
if (self::$db === false) {
$dsn = 'mysql:dbname=' . DBNAME . ';host=' . DBHOST;
self::$user = DBUSER;
self::$password = DBPASSWORD;
self::$name = DBNAME;
self::$host = DBHOST;
self::$db = parent::__construct($dsn, self::$user, self::$password);
}
}
+------------------------------------------------------------------------------- ------------------------------------+
| Grants for gestions@10.13.200.13 |
+------------------------------------------------------------------------------- ------------------------------------+
| GRANT USAGE ON . TO 'gestions'@'10.13.200.13' IDENTIFIED BY PASSWORD '*XXXXXX' |
| GRANT SELECT, INSERT, UPDATE, DELETE ON database.* TO 'gestions'@'10.13.200.13' |
+------------------------------------------------------------------------------- ------------------------------------+
2 rows in set (0.01 sec)
I don't really know what to show to you.
I expect to connect my PHP to my MySQL server.
Thanks a lot !
--- EDIT ---
That's a mistake. I put my local code, the code on the VM is the real IP.
Adding my user (Probably the problem ?)