Cannot connect to MySQL using PHP 7 The version of MySQL is 8.0.16. This is installed on an EC2 Linux and is a fresh install. I have run the mysql_secure_installation command after installation and was able to change the root password successfully and was also able to add a second user with basic privileges. 

To test the connection I made a simple script:

$link = mysqli_connect($dbhost, $dbuser, $dbpass);      
    if (mysqli_connect_error() ){
        echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    }else{
        echo "Connection successful";
    }


I have double checked the values of the variables and they are all correct. When I try to visit the URL it says:


  Debugging errno: 2054


How to resolve this?
I was able to find the answer through this thread And this is because MySQL uses an authentication plugin. You can read all the details on the forum.