How can the use of "root" as a default username in a PHP script impact the security and integrity of a database?

Using "root" as a default username in a PHP script can impact the security and integrity of a database because it is a common username used by attackers to attempt unauthorized access. To mitigate this risk, it is recommended to use a unique and secure username for database connections in PHP scripts.

// Connect to the database using a secure username
$servername = "localhost";
$username = "my_secure_username";
$password = "my_secure_password";
$dbname = "my_database";

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

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