<?php
$database_name = "database2";
try {
    $pdo = new PDO(
        "mysql:host=localhost;dbname=database2;charset=utf8",
        "username2",
        "password2",
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
    );
} catch(PDOException $e) {
    die("Erreur de connexion : " . $e->getMessage());
}