Sunday 31 March 2013

How to use a MySQL test script to verify if your MySQL server is allowing remote connection?

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. 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.
=====================
<?php
$link = mysql_connect(‘<server>’, ‘<username>’, ‘<password>’);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}
echo ‘Connected successfully’;
mysql_select_db(<database>);
?>
=====================

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.

No comments:

Post a Comment