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
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