Spring Semester 2007


Lab Four: HTTP: GET vs. POST. Installation of MySQL (optional this week).
Let's just write here the basic steps of installing MySQL.

Recall these steps are to be followed from the book (pp. 47-50).

Start by making sure you have a nobackup folder.

Copy the file from

/l/www/classes/a348/sum2006/software/mysql*
Move in the folder created by tar and run these commands:
./configure --prefix=/nobackup/[username]/mysql
make
make install
When this is done, configure MySQL as follows:
/nobackup/[username]/mysql/bin/mysql_install_db \
  --user=[username] \
  --datadir=/nobackup/[username]/mysql
With the server configured run this (make it a script) to start the server:
/nobackup/[username]/mysql/bin/mysqld_safe \
  --user=[username] \
  --pid-file=/nobackup/[username]/mysql/mysqld.pid \
  --log=/nobackup/[username]/mysql/mysqld.log \
  --socket=/nobackup/[username]/mysql/mysql.sock \
  --basedir=/nobackup/[username]/mysql \
  --datadir=/nobackup/[username]/mysql \
  --port=[your assigned mysql port] & 
You can call the above mysql_start and put it in ~/bin to refer to it again later, when needed.

Change the root password:

/nobackup/[username]/mysql/bin/mysqladmin \
  --port=[your port] \
  --socket=/nobackup/[username]/mysql/mysql.sock \
  -u root password '[password]'
Make a note of the password. I suggest we all use passw0rd for simplicity.

Now create yourself as an user:

bash-3.00$ cat ~/bin/root
mysql --socket=/nobackup/[username]/mysql/mysql.sock \
  --port=[your port] -u root -p

bash-3.00$ ./root
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.22-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> create user '[username]'@'silo.cs.indiana.edu' IDENTIFIED BY '[password]';
Query OK, 0 rows affected (0.00 sec)

mysql> create database demoOne;
Query OK, 1 row affected (0.03 sec)

mysql> grant all on demoOne.* to '[username]'@'silo.cs.indiana.edu';
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
bash-3.00$
Again, I think you need to make a note of your password.

I suggest you use n0pass. My password is in the book somewhere.

Now to stop the server you can do this:

/nobackup/[username]/mysql/bin/mysqladmin \
  --socket=/nobackup/[username]/mysql/mysql.sock \
  --port=[your port] -u root -p shutdown
With this you can go in and create tables in your database:

bash-3.00$ mysql --socket=/nobackup/dgerman/mysql/mysql.sock \
  --port=13297 --host=silo.cs.indiana.edu -u dgerman -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.22-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use demoOne
Database changed
mysql> create table dgerman_accumulator (
    ->   session_id char(8) primary key,
    ->   acc int,
    ->   modified timestamp
    -> );
Query OK, 0 rows affected (0.03 sec)
mysql> show tables;
+---------------------+
| Tables_in_demoOne   |
+---------------------+
| dgerman_accumulator |
+---------------------+
1 row in set (0.01 sec)
mysql> describe dgerman_accumulator;
+------------+-----------+------+-----+-------------------+-------+
| Field      | Type      | Null | Key | Default           | Extra |
+------------+-----------+------+-----+-------------------+-------+
| session_id | char(8)   | NO   | PRI |                   |       |
| acc        | int(11)   | YES  |     | NULL              |       |
| modified   | timestamp | YES  |     | CURRENT_TIMESTAMP |       |
+------------+-----------+------+-----+-------------------+-------+
3 rows in set (0.00 sec)
mysql>
This is taken from page 69, or so.

Now you can start entering data using insert:

insert into dgerman_acc (session_id, acc) values ('aabbccdd', 23);

Updated by Adrian German for A348/A548