How can developers ensure the secure transmission of passwords when connecting to a MySQL database in PHP?

To ensure the secure transmission of passwords when connecting to a MySQL database in PHP, developers should use SSL encryption to protect the data being transmitted over the network. This can be achieved by enabling SSL support in the MySQL server configuration and using SSL options when establishing the database connection in PHP.

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

$mysqli = new mysqli($servername, $username, $password, $database, null, null, array(
    MYSQLI_CLIENT_SSL,
    MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT
));

if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
} else {
    echo "Connected successfully";
}
?>