Here, you can find out how to work with our MySQL database pilot support service to enrich your personal home page. Advanced users can enable MySQL database support via iHome – Personal Settings by assigning a database access password, after which you will be assigned a MySQL user id. With a MySQL user id and database password, you can develop programs on the iHome server for applications such as a personal address book, online surveys, and more.

The following will help you to get started with the service.

Enable MySQL add-on service

You can enable the service via iHome – Personal Settings:

HKUST iHome Service: Personal Settings

If you forget your password, you can also use iHome Personal Settings to reset it. As MySQL database support is a pilot service, it is subject to change. If you encounter problems, please email cchelp@ust.hk

Access Your Database

Via phpMyAdmin

Before writing programs to access MySQL database, you can use phpMyAdmin to create the required tables:

HKUST iHome Service: phpMyAdmin

You can logon to phpMyAdmin using your MySQL user id and database password to work on your database, for example, creating a new table, flushing the table to reclaim space from deleted records, and exporting your database to files.

By writing CGI programs

You can use the following to access your database:

PHP: MySQL functions

PHP programmers should be aware that you will need to run your PHP script under the cgi-bin d directory and specify the path to the php cgi binary.

Here is sample PHP snippet connecting to the database:

 
      #!/usr/local/bin/php 
      <?php 
      ..... 

      /* Connecting, selecting database */ 
      $link = mysql_connect("mysql_host", "mysql_user", "mysql_password")  
         or die("Could not connect : " . mysql_error()); 
      echo "Connected successfully"; 
      mysql_select_db("my_database") or die("Could not select database"); 
      .....     

      /* Closing connection */ 
      mysql_close($link); 
      ?>

Sample Programs

You can obtain these sample programs from the internet:

PHP/MySQL Counter (PHP)

Log both unique visits and number of hits with this counter. It also has a top 10 listing to see which IPs are visiting your website most.

Traffic Source (Perl)

Pinpoint exactly who is sending traffic to your website. Traffic source will record URL statistics for websites that send visitors to your site. Statistics come with accompanying graphs in an easy-to- understand format. There is also a comprehensive and straightforward control panel and detailed setup instructions.

Backup / Restore your database

As a pilot service, support is limited for MySQL database. You are advised to back up your databases regularly to prevent loss of data:

  1. Logon to phpMyAdmin using your MySQL user id and database password.
  2. Select the database to back up from the left column, e.g. 1023db.
  3. Click on Export tab.
  4. Check the Save as file option.
  5. Click Go to save the database to your local hard disk.

Restoring your database is as easy as backing it up. To reload your backup to overwrite your database, you can do the following (but be aware that you will lose all changes since your last backup):

  1. Logon to phpMyAdmin using your MySQL user id and database password.
  2. Select your database from the left column, e.g. 1023db.
  3. Click all the check boxes next to the table names.
  4. Select Drop in With Selected: on the drop-down listbox, click Yes to confirm removal of all your data. (Note: You will lose all your data after this action until you successfully restore your last backup. However, changes on your database after your last backup will be lost.)
  5. Click on SQL tab.
  6. Click on Browse and select the SQL backup file you wish to upload to the server.
  7. Click Go to confirm the reload.

Additional References