Connection failed: No such file or directory Mysql - WSL
in PHP  mysqli needs 4 Paarameters

https://www.php.net/manual/de/function.mysqli-connect.php

So it should be

&lt;?php
$servername = "localhost";
$username = "root";
$password = "root";
$database = "mydatabase";

// Create connection
$conn = new mysqli($servername, $username, $password,$database);

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


echo "Connected successfully";
?>