Why do most web hosting providers still default to MySQL as the database standard despite potential limitations compared to PostgreSQL?

Most web hosting providers default to MySQL as the database standard because it is widely supported, has a large user base, and is generally easier to set up and use compared to PostgreSQL. While PostgreSQL may offer more advanced features and better performance in certain situations, MySQL remains the preferred choice for many hosting providers due to its familiarity and compatibility with popular applications and platforms.

// Example PHP code snippet connecting to a PostgreSQL database instead of MySQL

$host = 'localhost';
$database = 'my_database';
$user = 'my_user';
$password = 'my_password';

$dsn = "pgsql:host=$host;dbname=$database;user=$user;password=$password";

try {
    $pdo = new PDO($dsn);
    echo "Connected to PostgreSQL database successfully";
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}