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:

Test MySQL connection

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 make sure it is in the right directory.

Step 4. Access your website (depends on what directory the domain name is pointed to). Example

If you do not have a database yet, please create it by following the instructions on how to create a new MySQL database.

If you have further questions, please do not hesitate to contact our support team.

Test MySQL connection

(Visited 122 times, 1 visits today)