What are the advantages of using MySQL for data storage in PHP applications?

MySQL is a popular choice for data storage in PHP applications due to its reliability, scalability, and performance. It provides a robust and secure way to store and retrieve data, making it ideal for web applications that require frequent data manipulation. Additionally, MySQL is open-source and widely supported, with a large community of developers contributing to its ongoing development and improvement.

// Connect to MySQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";