How do I use PHP to access my MySQL database?

Please note: This support article is a guide for our Linux users only.
The following article explains how to connect to a MySQL database using PHP. A MySQL database can be accessed on our servers using all of the programming languages available on the server. Unlike Perl, PHP contains native MySQL connection support, so it is not necessary to include a module.

In order to access your MySQL database with the PHP, please follow these steps:

  1. Log into your Linux web server via Secure Shell.
  2. Type the following connection string to connect to your database:

    $link = mysql_connect('host', 'username', 'password') or die('Could not connect: ' . mysql_error());
    mysql_select_db('database') or die('Could not select database');

    • host: enter the MySQL server that you are assigned to, for example,
    • username: enter the username provided for your database
    • password: enter the password provided for your database
    • database: enter the name of the MySQL database

Comments are closed.

By using this website you consent to the use of cookies in accordance with our Privacy Notice. You may opt-out at any time in the Cookies section of the Privacy Notice page.