PHP语言中,通过使用MySQLi和PDO等扩展,可以实现与MySQL数据库的连接和操作。下面是一个基本的MySQL数据库连接示例,可供参考:

<?php
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "myDB";

// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);

// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}

echo "连接成功";

$conn->close();
?>