First Steps with MySQL
You will need access to the MySQL server on the orioles.acad.ece.udel.edu machine,
which is a linux box. Once you have an account that gives you access to this
machine and you know your user name and password for the MySQL server, you
will want to know the following about how to run MySQL.
Documentation:
You can find MySQL documentation at
http://dev.mysql.com/doc
We are using version 5.0 of MySQL.
Chapter 3, the Tutorial, probably contains more than you need to know, at least
for your first assignments using MySQL.
There are man pages for MySQL. To see them, add /usr/local/mysql/ to the PATH
in your .login file on orioles.
Running a MySQL session:
The basic commands that you will need in addition
to the SELECT command are the following:
-
ssh orioles.acad.ece.udel.edu
- log onto the machine where the MySQL server resides.
- mysql -u userid -p
- where userid is the userid that I gave you. MySQL will prompt
you for your password. This password is the one I sent you in an e-mail.
- show databases;
- displays the databases that you can access.
-
use company
- the use command connects you to the specified database.
- show tables;
- displays the names of the tables in the database.
You are now ready to type in the select commands. Here are some other commands
that you will find helpful (in addition to the help command):
- prompt \u>\d>
- Changes prompt so that it shows your user name and the
database you are using. Note that the command does not end with a semi-colon.
To get the default prompt back again, type prompt, again without a
semi-colon at the end.
- tee sessionfile
- from now on, everything you type and everything that MySQL
types back is recorded in the file named sessionfile. After you end the
session, you can use sftp to copy the file onto strauss or copland.
- notee
- this comand stops appending output to the file you declared in the
tee command.
- quit
- this command ends your session with MySQL.
- source filename
- reads and executes the MySQL commands written in the named
file. If you find it difficult to type long commands directly into MySQL,
put the commands into a file instead and use the source command to have
them executed. You will have to combine the source file(s) with the output
file to make one file for homework submission. Make sure that this is easy
to read. Lines that begin with # are comments.
- describe tablename;
- lists the columns for the table called tablename and some information
about them such as what domain type the values in each column belong to,
whether the NULL value is allowed, etc.