How can you securely synchronize a MySQL database without exposing the password in the source code?

To securely synchronize a MySQL database without exposing the password in the source code, you can store the password in a separate configuration file outside of the web root directory. This way, the password is not directly accessible to anyone browsing the website. You can then include this configuration file in your PHP script to access the password securely.

// config.php file outside of web root directory
<?php
$db_host = 'localhost';
$db_user = 'username';
$db_pass = 'password';
$db_name = 'database_name';
?>

// synchronize.php file in web root directory
<?php
include('../config.php');

// Connect to MySQL database
$connection = new mysqli($db_host, $db_user, $db_pass, $db_name);

// Synchronize database
// Add your synchronization code here
?>