Knowledge base
1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Connect a Cloud Server to an external database
This guide explains how to connect to an external database from a Cloud Server.
Preamble
- It is possible to connect to MySQL via SSL (external or not) - this must be specified when establishing the connection.
- The MySQL port
3306
is closed by default - to open it, refer to this other guide. - Infomaniak does not install
PDO_DBLIB
.
Install PHP_PDO_ODBC
Prerequisites
- Have the PHP Extensions menu on the Infomaniak Manager in the Cloud Server section (if not, it will be necessary to upgrade the Cloud Server).
It is possible to install the PHP_PDO_ODBC
extension from the PHP Extensions menu of your Cloud Server:
- Click here to access the management of your product on the Manager Infomaniak (need help?).
- Click directly on the name assigned to the relevant product.
- Click on PHP Extensions in the left sidebar.
- Click on the blue button Install an extension.
- Select the extension
PHP_PDO_ODBC
. - Confirm the installation.
Configure the 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 redefine it statically in the .odbc.ini
or in the user's home directory ‍~~/.odbc.ini‍
or also dynamically in the PHP code.
Example with the driver FreeTDS
defined in advance, it is also necessary to specify the version of the driver at the end of the pdo
object declaration:
$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: