Better experience and fast, secure way to create a connection with MariaDB.
// Config.php
$mariadb = ini_get('pdo_mysql.default_socket');
$pdo = new PDO("mysql:unix_socket=$mariadb;dbname=test", 'root', '');
if($pdo){
echo "Database connection success!";
}