Connect to Aiven for MySQL® with PHP
This example connects to an Aiven for MySQL® service from PHP, making use of the built-in PDO module.
Variables
These are the placeholders to replace in the code sample:
Variable | Description |
---|---|
MYSQL_URI | Service URI for MySQL connection, from Aiven Console > the Overview page of your service |
Prerequisites
-
Download CA certificates from Aiven Console > the Overview page of your service. This example assumes it is in a local file called
ca.pem
. -
Make sure you have read/write permissions to the
ca.pem
file and you add an absolute path to this file into the code:$conn .= ";sslmode=verify-ca;sslrootcert='D:/absolute/path/to/ssl/certs/ca.pem'"
note
Your PHP installation needs to include the MySQL functions (most installations have this already).