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.
MySQL Database Accounts Policy
- For students: anyone with CGI enabled on Fling.seas automatically has a MySQL database available for use. Please see the CGI Scripts article for more details on requesting access to Fling.
- For faculty: MySQL accounts are also available on Alliance.seas - please email firstname.lastname@example.org to discuss your database needs.
Your MySQL Account
Step 1 - Setting your Database Password
To change your MySQL database password on Fling.seas go to: https://www.seas.upenn.edu/mysql/fling.html.
If you are getting an "Access Denied" error, it means you are not currently authenticated to have a MySQL account. Please contact cets@seas.
Step 2 - Connect to MySQL Database
Once you've created your MySQL database, logon to Eniac.seas.upenn.edu and connect by typing the following at the prompt:
/usr/bin/mysql -u DBUSERNAME -h DBSERVER -p DBNAME
with the following replacements of the bolded terms above:
* Replace DBSERVER with the correct database servername for your site. This is: fling.seas.upenn.edu
* Replace DBUSERNAME with your own mysql username. This is your SEAS account username.
* Replace DBNAME with your own mysql databasename. The name of your database is the same as your SEAS account username.
For example: /usr/bin/mysql -u jsmith -h fling.seas.upenn.edu -p jsmith
Step 3 - Use SQL Commands to create and manipulate your database
After completing Step 2, you will be prompted for your MySQL password (this is the password you set in Step 1). Once successfully logged in you'll be brought to the MySQL prompt, where you can then issue SQL commands directly to the MySQL server.
Here are some of the basic MySQL commands:
|Display all databases|
mysql> show databases;
|View tables of a Database (must be connected to the Database)|
mysql> show tables;
|View contents of a table (must be connected to the Database)|
mysql> select * from TableName;
|Create a table|
mysql> CREATE TABLE table_name
For Example - To create a table called address_book with three columns: first_name, last_name, and phone_number, 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
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.
Connecting to MySQL using PHP
To connect to your MySQL database, use the following function:
mysql_connect("localhost", "your_db_username", "db_password")