How to test MySQL connection?

You can test MySQL connection by creating a testmysqlconnection.php file (recommended to identify the content of the file) or any desired file name and access it with your website. Kindly follow the instructions below:

Step 1: Open a notepad or any note editor from your computer.
Step 2: Add the following script.

$connection= mysql_connect(‘hostname’,’dbuser’,’dbpassword’);
if (!$connection) {
die(‘Could not connect to MySQL: ‘ . mysql_error());
} else {
echo ‘Connection OK’;
mysql_close($connection); ?>

Step 3: Save the file as testmysqlconnection.php or any desired file name, upload it to your webspace and ensure it is in the right directory.
Step 4: Access your website (depends on what directory the domain name is pointed to). Example

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support