MySQL-5

From Helpme

Jump to: navigation, search

Contents

Availability

MySQL5 can be used on Linux machines in Engineering Design Center.

Preparation

Account Creation

To use MySQL, you must first have a MySQL account created for you. This account is separate from your normal DC account. To request one, please e-mail support@engr.scu.edu

Your MySQL username will be identical to your DC username, but the password is independent. (By default it is set to your Access Card ID with all the leading zeroes)


Database Name

Your database name will be of the format:

sdb_<username>

If, for example, your username were "testuser", your database would be named:

sdb_testuser


Database Server

The database server runs on a single system. Its hostname is:

dbserver.engr.scu.edu

Running

  • To setup MySQL in your environment, type:
setup mysql5
  • Run MySQL by executing:
mysql -h dbserver.engr.scu.edu -p -u <username> <db_name>
This will prompt you for your MySQL password. (note: this might be different from your DC account password)
Once authenticated, you will be left at the mysql> prompt.

Web Management Interface (phpMyAdmin)

  • Go to: https://dagobah.engr.scu.edu/phpMyAdmin/
  • Pop-up requesting "SCUDC Unix Authentication"
    • Username: <Enter your Design Center username>
    • Password: <Enter your Design Center UNIX password>
  • phpMyAdmin login page
    • Username: <Enter your MySQL username>
    • Password: <Enter your MySQL password>

Connecting via PHP

You can connect to your MySQL database via PHP from the Design Center webserver. A very simple connection example follows:

  • Hostname: dbserver.engr.scu.edu
  • Port: 3306
  • Username: <Your MySQL username>
  • Password: <Your MySQL password>
  • Database: sdb_<username>

Simple Mysqli example

ini_set('display_errors','On');
error_reporting(E_ALL);

$db_host = "dbserver.engr.scu.edu";
$db_user = "testuser";
$db_pass = "testpass";
$db_name = "sdb_testuser";

$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name)
        or die("Error" . mysqli_error($conn));

$query = "SHOW DATABASES";

$result = $conn->query($query);

echo "Connected.  Dumping DB list:<br>\n";
while($row = mysqli_fetch_assoc($result)) {
        echo $row['Database'] . "<br>\n";
}       

mysqli_close($conn);

Notes

  • To change your MySQL password, at the mysql> prompt run:
mysql> set password = password("yournewpassword");

Further Reading

  • Thorough MySQL documentation can be found at the MySQL website.
  • A tutorial on connecting to MySQL through PHP is available here.
Personal tools