MySQL test script for PHP

How Do I Setup A MySQL Test Script? This article will show you how to use a MySQL test script to verify if your MySQL server is allowing remote connection as well as to confirm if you are using the proper server address, database name, username and password. This can be used for both Linux and Windows based server however if you are using this on Windows please be sure that you have enabled PHP functionality as this script does require PHP.

  1. Connect to the server where are hosting the MySQL server instance.
  2. Open up a text editor and use this example however be sure to replace the server, username, password and database variables with your own.

    $link = mysql_connect(‘<server>’, ‘<username>’, ‘<password>’);
    if (!$link) {
    die(‘Could not connect: ‘ . mysql_error());
    echo ‘Connected successfully’;
  3. Save the script into a PHP file and call it something that you will remember. Make sure that where you save the file is also web accessible.
  4. Open up a web browser can enter the path of where the script is located. If the test is successfully you will see the message "Connected Successfully". If not then you will receive a blank screen meaning that either you can not connect remotely or the username, password, server or database name is incorrect and you will need to recheck the value.