How to use MySQL and MariaDB simultaneously with PHP? Resolved

By default MySQL is started on port 3306 and MariaDB on port 3307.
Here is an example using PDO to access a database named wordpress installed on MySQL and MariaDB :
$mysql = new PDO('mysql:host=127.0.0.1;port=3306;dbname=wordpress', 'root', '');
$mysqlStmt = $mysql->query("SELECT * FROM wp_comments");
var_dump($mysqlStmt->fetchAll(PDO::FETCH_ASSOC));

$mariadb = new PDO('mysql:host=127.0.0.1;port=3307;dbname=wordpress', 'root', '');
$mariadbStmt = $mariadb->query("SELECT * FROM wp_comments");
var_dump($mariadbStmt->fetchAll(PDO::FETCH_ASSOC));
#10Edited 1 year ago

You must be logged in to post an answer

Sorry, this website uses features that your browser doesn’t support. Upgrade to a newer version of Firefox, Chrome, Safari, or Edge and you’ll be all set.