I am using php 7.4 in ubuntu. and my mysql version is 8.0. I am able to connect to database in navicat using root but i cannot connect using php .
<?php
$servername = "localhost";
$username = "root";
$password = "P@ssword123";
$dbname = "test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
echo "<br>";
// Check connection
if ($conn->connect_error) {
die("Connection failed: ". "<br>" . $conn->connect_error);
}
echo "Connected successfully";
I try using oop and procedural but i dont think the problem is in the syntax.