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 - Who is allowed to have a MySQL account?
Students are only authorized to create a MySQL database if it is needed for one of their current courses, in which everyone in the course will be needing MySQL. After the course is over, the data and the account will be removed.
MySQL accounts are also available by special arrangement with CETS (for e.g. you are doing an Independent Study and need a MySQL database). In these types of cases, please email cets@seas.upenn.edu to discuss your database needs.
Step 1 - Create MySQL Database Account
To create a MySQL database on Fling.seas go to: https://www.seas.upenn.edu/mysql/fling-l.html.
Fling.seas is the newest CGI web server at SEAS. It is faster and more powerful than it's predecessor. [more about Fling]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 Eniac username.
* Replace DBNAME with your own mysql databasename. The name of your database is the same as your Eniac 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")
Related Articles
WWW CGI Scripts on Eniac, Fling, and Fling
How
do I create a Webpage?
