I'm trying to connect my Wordpress 6.1.1 installation installed on an Azure VM (Ubuntu) to my DB, also installed on Azure. I ran the "php -m" command to get the list of available PHP extensions on the server and I got this list:
Core ctype curl date dom fileinfo filter ftp hash iconv json libxml mbstring mysqlnd openssl pcre PDO pdo_sqlite Phar posix readline Reflection session SimpleXML SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib
I'm trying to use PDO (which is listed and therefore available) to connect with the following code in wp-config.php
define( 'DB_NAME', 'nome_database' );
define( 'DB_USER', 'nome_utente' );
define( 'DB_PASSWORD', 'password' );
define( 'DB_HOST', 'host' );
define( 'DB_CHARSET', 'utf8' );
$pdo = new PDO( "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASSWORD,
array( PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING ) );
but I get the following error:
Fatal error: Uncaught PDOException: could not find driver in /home/site/wwwroot/wp-
config.php:57 Stack trace: #0 /home/site/wwwroot/wp-config.php(57): PDO-
>__construct('mysql:host=MYHOST...', 'USERNAME...', '***********', Array) #1
/home/site/wwwroot/wp-load.php(50): require_once('/home/site/wwwr...') #2
/home/site/wwwroot/wp-blog-header.php(13): require_once('/home/site/wwwr...') #3
/home/site/wwwroot/index.php(17): require('/home/site/wwwr...') #4 {main} thrown in
/home/site/wwwroot/wp-config.php on line 57
Can you help me understand what's going on? Thanks a lot!