How to get a MySQL database account

The MySQL database server is the world's most popular open source database. CETS provides MySQL database accounts for students in specific courses and for CGI-enabled accounts.

Set Your Database Password

Use the SEAS MySQL Account Management page to change your MySQL database password on or

If you get an Access Denied error, you are not authenticated to have a MySQL account. Please contact

Connect to MySQL

Once you've created your MySQL database, log onto and connect by typing the following at the prompt:

/usr/bin/mysql -u DBUSERNAME -h DBSERVER -p DBNAME

For example:

/usr/bin/mysql -u jsmith -h -p jsmith

This will display the MySQL prompt, where you can type SQL commands:


Here are some basic SQL commands:

Display all databases:

mysql> show databases;

View the tables in the current database:

mysql> show tables;

View the records in a table in the current database:

mysql> select * from table_name;

Create a table:

mysql> CREATE TABLE table_name (
     column_name1 data_type,
     column_name2 data_type

For example, to create a table called address_book with three columns:

Use the following command:

mysql> CREATE TABLE address_book (
    first_name VARCHAR(25),
    last_name VARCHAR(25),
    phone_number VARCHAR(15)

Display the column details of the a table:

mysql> describe TableName;

Insert data into a table:

mysql> INSERT INTO table_name VALUES (value1, value2,....);

For example, to insert a record into the address_book table, use the following command:

mysql> INSERT INTO address_book (first_name, last_name, phone_number)
    VALUES ('John', 'Smith', '215-895-6955');

For complete SQL syntax information, see the MySQL Manual.

Connect to MySQL with PHP

To connect to your MySQL database with PHP, use the following function:

mysql_connect("localhost", "your_db_username", "db_password")

Related Articles

© Computing and Educational Technology Services | Report a Problem | 215.898.4707