CSCI A348/548
Lab Notes Fourteen

Fall 2000


Using mySQL on burrowww
Here's a quick summary of what we did last night and the lecture before the break:
burrowww.cs.indiana.edu% echo $PATH
/u/dgerman/bin:/home/user1/mysql/bin:/usr/local/gnu/bin:/usr/bin:/usr/local/bin:/usr/sbin:/usr/ucb:/usr/bin/X11:/usr/openwin/bin:/usr/dt/bin:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/local/gnu/bin
burrowww.cs.indiana.edu% grep -i mysql ~/.cshrc
        /home/user1/mysql/bin \
burrowww.cs.indiana.edu% mysql -ua348 -pa348AG
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 78 to server version: 3.23.27-beta-log

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

mysql> exit
Bye
burrowww.cs.indiana.edu% mysql -ua348 -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 79 to server version: 3.23.27-beta-log

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

mysql> show databases;
+----------+
| Database |
+----------+
| a348     |
| bassoon  |
| classes  |
| mysql    |
| proj     |
| test     |
+----------+
6 rows in set (0.00 sec)

mysql> create database dgerman;
ERROR 1044: Access denied for user: 'a348@localhost' to database 'dgerman'
mysql> select database();
+------------+
| database() |
+------------+
|            |
+------------+
1 row in set (0.01 sec)

mysql> use a348
Database changed
mysql> select database;
ERROR 1064: You have an error in your SQL syntax near '' at line 1
mysql> select database();
+------------+
| database() |
+------------+
| a348       |
+------------+
1 row in set (0.00 sec)

mysql> show tables;
Empty set (0.01 sec)

mysql> create table dgerman_student (
    ->   name        varchar(20)      not null, 
    ->   gender      enum ('f', 'm')  not null,
    ->   student_id  int unsigned     not null  auto_increment primary key
    -> );
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+-----------------+
| Tables_in_a348  |
+-----------------+
| dgerman_student |
+-----------------+
1 row in set (0.00 sec)

mysql> describe dgerman_student;
+------------+------------------+------+-----+---------+----------------+---------------------------------+
| Field      | Type             | Null | Key | Default | Extra          | Privileges                      |
+------------+------------------+------+-----+---------+----------------+---------------------------------+
| name       | varchar(20)      |      |     |         |                | select,insert,update,references |
| gender     | enum('f','m')    |      |     | f       |                | select,insert,update,references |
| student_id | int(10) unsigned |      | PRI | NULL    | auto_increment | select,insert,update,references |
+------------+------------------+------+-----+---------+----------------+---------------------------------+
3 rows in set (0.00 sec)

mysql> select * from dgerman_student;
Empty set (0.00 sec)

mysql> insert into dgerman_student values 
    ->   ('Abby', 'f', NULL), 
    ->   ('Kyle', 'm', NULL); 
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from dgerman_student;
+------+--------+------------+
| name | gender | student_id |
+------+--------+------------+
| Abby | f      |          1 |
| Kyle | m      |          2 |
+------+--------+------------+
2 rows in set (0.01 sec)

mysql> delete from dgerman_student;
Query OK, 0 rows affected (0.02 sec)

mysql> select * from dgerman_student;
Empty set (0.00 sec)

mysql> show tables;
+-----------------+
| Tables_in_a348  |
+-----------------+
| dgerman_student |
+-----------------+
1 row in set (0.00 sec)

mysql> drop table dgerman_student;
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
Empty set (0.00 sec)

mysql> exit
Bye
burrowww.cs.indiana.edu% exit
burrowww.cs.indiana.edu% 
Remember that you go in as one and the same user so please


Last updated on November 29, 2000, by Adrian German for A348/A548