Knowledge base
1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Connecting a Cloud Server to an external database
This guide explains how to connect to a external database from a Cloud Server.
Preamble
- It is possible to connect in SSL to MySQL (external or not) - to be specified when establishing the connection.
- The MySQL port
3306
is closed by default - to open it, be aware of this other guide. - Infomaniak does not install
PDO_DBLIB
.
Install PHP_PDO_ODBC
Prerequisites
- Have menu PHP Extensions on the Manager Infomaniak in the game Cloud Server (if not necessary) to make the Cloud Server evolve).
It is possible to install the extension PHP_PDO_ODBC
from the menu PHP Extensions Your Cloud Server:
- Click here in order to access the management of your product on the Manager Infomaniak (Need help?).
- Click directly on the nameallocated to the product concerned.
- Click on PHP Extensions in the left side menu.
- Click the blue button Install an extension.
- Choose the extension
PHP_PDO_ODBC
. - Validate the installation.
Configure connector
The driver configuration is already defined in /etc/odbcinst.ini
:
[FreeTDS]
Description = MS SQL database access with Free TDS Driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
There is no need to re-define it statically in the .odbc.ini
or in the home of the user ‍~~/.odbc.ini‍
or dynamically in the PHP code.
Example with driver FreeTDS
defined in advance, the driver version must also be specified at the end of the declaration of the object pdo
:
$con = new PDO('odbc:Driver=FreeTDS;Server=__SERVER IP__;Port=3306;DATABASE=__DATABASE NAME__;UID=__USERNAME__;PWD=__PASSWORD__;TDS_Version=8.0');
Link to this FAQ: