Conexion Php y Mysql PDO

<?php
    $servidor = "mysql:dbname=nombre;host=localhost";
    $user = "root";
    $pass = "password";
    
    try {
    
        $pdo = new PDO($servidor, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
        
    } catch (PDOException $e) {
        echo "Error en la conexion" . $e->getMessage();
    }
?>