Test connection to MySQL Database using PHP

Create a blank new file called “testmysql.php” (without the quotes) and paste the next code snippet:


$myLink = mysqli_connect( 'localhost', 'root', '' ); 

if ( !$myLink ) { 

    die( 'Could not connect to MySQL: ' . print_r( mysqli_error_list( $myLink ) ) ); 


echo 'Connection OK'; 



Now you need to navigate to the corresponding page:


You should see a “Connection OK” message and if there’s an error, it’ll display the error number and description.