Building and Administering a Web-Database Server (Linux ....doc

29
Web and Database Integration: Building and Administering a Web-Database Server

Transcript of Building and Administering a Web-Database Server (Linux ....doc

Page 1: Building and Administering a Web-Database Server (Linux ....doc

Web and Database Integration:

Building and Administeringa Web-Database Server

Jeffery Engel

CS514 -- Database Theory and Implementation3 April 2001

Page 2: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 1

INTRODUCTION

The topic of web and database integration appealed to our group as an opportunity to

explore a popular database-related topic through practical application. We initially

planned to use tools available under the campus UNIX server to access the Oracle

database. After communicating with the System Administrator however, we discovered

that our options were too limited. Consequently, we decided to set up a web-database

development system over which we had administrative control. We could thus install the

necessary tools to allow us to investigate a number of representative scripting and other

web-database access methods about which the group members had expressed interest but

which otherwise were not available to us.

As group leader and someone with both access to a networked campus server and the

desire to broaden my experience with UNIX administration, I took on the role of building

the basic system on which group members could develop their projects. We thus

installed the tools necessary to implement a range of database-access techniques. In the

process, we gained a general overview of the topic for use as our group report, and team

members could use the system to develop and finally report on their implementations of a

particular web-database access method for the individual reports. I too had planned

initially to report on using a web-scripting language for database access, but my

experience with administering a web-database server not only provided me with

knowledge of a number of scripting languages, but it also gave me insight into what is

necessary to run a working web-database server, including web server configuration and

database administration. As such, the issues involved in installing and administering a

modern web-database server seemed to be a logical topic for this report.

THE OPERATING SYSTEM

We chose Linux (www.redhat.com), the free UNIX implementation, as our platform

operating system (OS). UNIX traditionally has been the OS of choice for web-servers,

due to its multi-tasking efficiency, reliability, configurability, and network-ready

features. Only recently have offerings from Microsoft begun to challenge UNIX as a

viable platform. Many businesses have turned to the industry support of Windows NT

Page 3: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 2

Server, itself an impressive and robust modern operating system featuring object

oriented, multi-threaded, micro-kernel design. The limited, predominantly vendor-

specific range of tools available under Windows NT, as well as NT’s hefty price

convinced us that Linux was a good choice in this case. Beyond that, the open source

philosophy of Linux makes it by far the best choice for students who wish to experiment,

and produce working demonstrations, as well as examine components of the system that

would otherwise be transparent or inaccessible to them.

The dark side of the combination of Linux’s out-of-the-box networking readiness and

configurability is that security is correspondingly lax. This is an area for future

improvement in terms of many of the default OS configurations available. Without the

installation and proper configuration of supplementary tools for security, the server is in

effect open to the world. For despite the evolution of user-level authentication tools and

security measures native to Linux, the standard methods of remotely accessing a UNIX

server, namely telnet and ftp, send all transmissions including usernames and passwords

in plain text over the network. This is clearly unacceptable. A secure server is the

crucial foundation for any web-database source, not only for protection of the data itself,

but also for preservation of the long hours that go into development of such a system.

One solution is to disable the traditional telnet and ftp utilities and implement one of the

available “secure shell” tools. These look and act just like telnet and ftp, with both

functions integrated into one utility, but they encrypt all transmissions between the client

and server. We chose “ssh” (www.ssh.com) as our secure shell, as it offers both a UNIX

server and an excellent Windows client secure shell implementation free for non-profit or

educational use.

This took care of user-level network security, including all remote command-line

interaction with the server, which we would use to initially secure and construct our

database. As an additional measure, I configured the system to accept such connections

only from a specified limited range of IP addresses. In this way, we could closely control

who could directly access the command line and file system of the server, and legitimate

communications were protected through encryption.

Page 4: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 3

THE DATABASE SERVER

As mentioned above, we would have liked originally to develop under the campus UNIX

server using Oracle. Even as we prepared to build a Linux development system under

which we could have the freedom to install the range of web-scripting tools we planned

to study, we hoped that we could possibly use these to access Oracle remotely. But

among other things, at that early stage we discovered that we did not possess the

permissions under Oracle necessary to create and tailor access permissions for an

independent database for use as our development web-database.

Next, we considered installing the recently-released Oracle8i offering for Linux

(http://technet.oracle.com/software/products/oracle8i/software_index.htm). But we found

that the system requirements of Oracle8i were too great for the hardware we had

available for a server. The source code alone comprises a 500MB archive, including the

Enterprise Edition server, Management and Integration tools, and Oracle Client. All told,

a typical Oracle installation is around 2GB, requiring a minimum of 128MB RAM.

While this may seem excessive, it shows the extent to which Oracle has built the most

powerful and feature-filled database currently available. A recent article (Greenspan,

1998) emphasizes that Oracle's vision includes not only a suite of cutting-edge database

components but also a commitment to web integration that includes their own web server

distribution. This is reportedly so closely integrated to the Oracle database itself that

many of the Oracle programming extensions, such as PL/SQL and SQL/J (SQL-

embedded Java) are available to facilitate web-database programming. Oracle's

integration with Java is especially impressive.

In the face of such overwhelming system requirements, we chose instead to implement

what has become a popular Linux standard, the MySQL RDBMS (www.mysql.com).

MySQL supports the ANSI SQL92 and ODBC L0-2 standards, and it minimizes

extensions to these for the sake of portability. The most important functions lacking from

MySQL seem to be the sub-select (i.e., nested selects), foriegn key constraints, and

triggers. In defense of this, MySQL was designed specifically to be optimized for speed

Page 5: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 4

when working with large databases, and as such, it leaves some functionality to be

implemented by the interface programmer. The authors have some interesting comments

about how to work around the above missing functions (http://www.mysql.com/doc/M/i/

Missing_functions.html). In any case, we appreciated that the MySQL package has very

light wieght system requirements and runs very efficiently on a server with limited

resources. Details of the MySQL installation are in Appendix A.

On a final note, whereas Oracle seems currently only to offer the Enterprise Edition

under Linux for download from their website, we later found that we could order

Oracle8i Lite on CD. We have received this edition, and we may attempt to install it

under our development system in order to further explore Oracle's web interface options.

This would also give us an opportunity to work with complete control over an Oracle

database, allowing us to examine the administrative functions we have discussed in class

that are not available to us under the campus UNIX server.

THE WEB SERVER

Next, we chose Apache as our web server (www.apache.org). This was a clear choice, as

Apache has been and remains the most widely used web server on the Internet.

Developed by a group of volunteers, Apache not only offers a web server based on

cutting-edge technology, but it is free. It is perhaps also the most configurable web

server available, and it supports the widest range of tools for web-database integration.

This is due, again, to the Open Source philosophy, which makes source code freely

available to scrutiny for purposes of improvement, extension, and compatibility among a

community of programmers and users.

The Apache Group provides a number of basic extensions to the web server, which

enabled us to configure it for uses beyond simply an HTML server. In developing a web-

database system for example, one must enable functions for interfacing with a database

server and for producing dynamic HMTL content generated from data returned by an

SQL query. Many of these functions are provided by extensions to Apache written in

Perl, and a massive library of these is found at the Comprehensive Perl Archive Network

Page 6: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 5

(www.cpan.org). In order for Apache to use these "Perl modules," the base package

called "mod_perl" must be linked with the web server source. This provides Apache with

an interface to the Perl language interpreter. Then the DBI ("Database Interface") Perl

module, for instance, provides Apache with a foundation-standards database interface

that may then be extended to a range of popluar specific database implementations using

the DBD modules. In our case, DBD::MySQL provided the web server with an interface

to the MySQL server. Other DBD modules include Oracle, Informix, JDBC, ODBC, and

Sybase, among others, encompassing all the major standard interfaces and vendors.

In order to enable many of the above extensions, as well as provide a secure environment

under which Apache is allowed to access the file system and execute commands, the

system administrator must work extensively to configure the web server. These

configurations include specifying the directory under which web scripts reside, and which

directories Apache and the scripts themselves may access. Scripts are usually limited to

running under the "cgi-bin" system directory. In this way, the system administrator may

keep track of all the executable web scripts on the system, including those submitted by

other users. For some of the embedded scripting languages we examined, this

requirement may be relaxed, as these languages have limited functionality in terms of

what they can do with the file system. For example, while a CGI web script can be easily

written in C to delete files on the server, embedded scripting languages do not allow this

and are thus safer to leave relatively uncontrolled.

This, too, is where the system administrator specifies that users may create web-

accessible directories under their personal accounts on the server and what they are

allowed to do there. This enabled me to create an environment under which group

members could work independently on their individual research. A detailed account of

the Apache installation and configuration on our development system is included in

Appendix A.

Page 7: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 6

THE LANGUAGE TOOLS

While we have discussed above the issues of database and web server integration,

scripting and other types of languages provide the programming tools necessary to

complete this integration and tailor the web-database interface to a specific use. Simply

put, the programmer uses these languages to take input sent by a user's web browser, to

build and execute SQL queries to the database server, and finally to produce output

HMTL with the data returned by the results of that query.

We chose one or two examples in each case from a representative range of languages

available for modern web-database integration. The first type, CGI Scripting, involves

using languages that tend to be native to the OS distribution itself, so rather than having

to install these tools, the major effort here was in configuring the web server to work with

them. These methods are all characterized by an external program called from an HTML

page, and include sh-shell scripts, Perl scripts, and C programs, among other options. As

these were more traditional methods, somewhat outmoded by the newer embedded

scripting languages, I chose to implement a series of simple tests using these methods and

focus on database-access by utilizing the strengths of the newer, more sophisticated

languages. Nevertheless, external CGI scripts remain a viable alternative to web-

database integration since most database vendors provide, for example, libraries of C

functions which may be used to access the database from such scripts.

The second type of web-database integration language is the embedded scripting

language. These languages include PHP, ePerl, ASP and others. We implemented PHP

(www.php.net) and ePerl (http://www.engelschall.com/sw/eperl) on the development

system, as well as the Microsoft-native ASP running under an NT Workstation

environment. The former two Linux-based methods required installation of extension

packages (detailed in Appendix A) to allow Apache to recognize and interpret scripting

code embedded in HTML pages residing on the server. I breifly explored ePerl and

implemented a preliminary test database on the group web page, which allows the user to

search for, insert, and delete records. I also contributed to some of the PHP "Job Bank"

Page 8: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 7

database development, as we found PHP to be a very good solution, due to its gentle

learning curve and ease of use.

We were able not only to implement the third type of language on our development

system, but also use it to access our development database server remotely from the

campus UNIX server. This speaks to the power, flexibility, and portability of Java-based

and similar cutting-edge web-database integration languages. Administration of these

solutions involved installing the Java Development Environment, including the Java

runtime interpreter (www.blackdown.org, www.javasoft.com) for running Java on the

server, however, as these tend to be so-called "client-side" methods, solutions involving

Java applets, for instance, require the client, too, to have this functionality installed.

Examples of some of the web-database integration solutions mentioned above may be

viewed on the group homepage running on our development system [no longer

functional].

THE DEVELOPMENT DATABASE AND WEB PAGES

After having installed and configured the system components discussed above, we were

able to quickly build a test database for use in exploring the individual web-database

interface tools. I have included a script detailing creation of this database in Appendix B.

This process involved not only building the database structure, but also administering its

permissions to allow for anonymous web access. This was accomplished by creating an

anonymous "wildcard" web user with limited permissions, able only to view records, and

insert personal demographic data, as would be the case, for instance, with an online job

bank database.

Beyond web pages designed to enable a user to search for data in the "Job Bank," we

found it helpful as database administrators to quickly establish some means of entering

data to populate the database. Doing so at the command line is tedious, whereas the web-

database integration methods we explored in our research provided an excellent way to

rapidly develop easy-to-use GUI-based methods to do so over the web.

Page 9: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 8

CONCLUSION

In conclusion, while administration of a web-database server is not a simple matter, there

is perhaps no better way to learn intimately the elements involved in web and database

integration. We found Linux to be a good choice for our development system due to its

amenability to experimentation and its openness, as well as the many tools available for

web-database integration. Such would not unfortunately have been the case under

Microsoft Windows. But just as Microsoft's proprietary impetus lends its products

consistency, clarity, and ease-of-configuration, Linux-based web-database solutions tend

to be abstruse and difficult to administer, though powerful. This is hopefully an area that

will improve with the growing popularity of Linux and Open Source solutions.

Page 10: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 9

BIBLIOGRAPHY

Dice, Richard. “Choosing the Right Database System.” <http://hotwired.lycos.com/ webmonkey/backend/databases/tutorials/tutorial1.html>. Lycos, Inc. (Carnegie Mellon University), 15 Jun. 1998. [Linux, Apache, MySQL, ePerl]

Gilmore, W.J. “MySQL Administration.” <http://www.devshed.com/Server_Side/ MySQL/Administration>. ngenuity, 30 Mar. 1999.

Greenspan, Jay. “The Internet According to Oracle.” <http://hotwired.lycos.com/ webmonkey/98/46/index3a.html?tw=backend>. Lycos, Inc. (Carnegie Mellon University), 20 Nov. 1998.

Matthew, Niel and Richard Stones. Beginning Linux Programming. Chicago: Wrox Press, 1996. [HTML Forms, Apache CGI Server]

Page 11: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 10

APPENDIX A

MySQL, Perl, Apache, mod_perl, ePerl, PHP3 INSTALLATION PROCEDURES==================================================================

System: RedHat Linux 6.2 -- Kernel 2.2.14-5.0 on i686Glibc-2.1.3

Packages:MySQL (www.mysql.com)Perl-5.005 (www.cpan.org)From CPAN:

MIME-Base64-2.11URI-1.11HTML-Tagset-3.03HTML-Parser-3.18libnet-1.0703Digest::MD5-2.12libwww-5.50CGI.pm-2.45DBI-1.14Data-ShowTable-3.3Msql-Mysql-modules-1.2215 (DBD modules)

ePerl-2.2.14 (www.engelschall.com/sw/eperl)apache-1.3.17 (www.apache.org)php-3.0.18 (www.php.net)mod_perl-1.25 (www.cpan.org)

==================================================

* Remove all old Perl, Apache, etc. binaries, sources, dirs, etc.

* Unzip, untar, and install MySQL:./configure --prefix=/usr/local/mysqlmakemake installscripts/mysql_install_bdadduser mysqlchown -R mysql /u/l/mysqlchgrp -R mysql /u/l/mysqlcp supporfiles/mysql.server <start-script location (/etc/rc...)>/u/l/mysql/bin/safe_mysqld --user=mysql &/u/l/mysql/bin/mysqladmin -u root -p password

<enter new mysql root password>" " -u rooot -h saass -p password

<enter new mysql host password>

* Unzip, untar, and install Perl (Cf).This creates /usr/bin/perl binary, /usr/lib/perl5 libraries

containing_____.pm perl modules.

* Unzip, untar, and install above CPAN modules, in above order, in prep for

mod_perl install. For each:

Page 12: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 11

$ perl Makefile.PL$ make$ make test# make install

These are installed under /usr/lib/perl5 subdirs.

* Install ePerl:

$ perl Makefile.PL$ make$ make test$ make install

This installs ePerl modules Parse::ePerl and Apache::ePerl under/usr/lib/perl5/site_perl/5.005/i686-linux/...

.../Parse/ePerl.pm

.../Apache/ePerl.pm

* Unzip, untar, and install Apache:

$ ./configure --sysconfdir=/etc/httpd/conf--datadir=/home/httpd--logfiledir=/var/log/httpd--enable-modules=most--enable-shared=max--disable-rule=WANTHSREGEX

$ make# make install

* Test Apache: # ln -s /usr/local/apache/bin/apachectl /usr/sbin/apachectl# apachectl restart$ lynx localhost

* Edit /etc/httpd/conf/httpd.conf to tailor to server, enable cgi, shtml, etc:

ServerAdmin [email protected] 130.191.247.69DocumentRoot "/home/httpd/html"

To allow includes under /home/httpd/html:-----------------------------------------<Directory "/home/httpd/html">

...Options Indexes FollowSymLinks MultiViews Includes

^^^^^^^^...

</Directory>

To allow users to set up "public_html" directories under theirhome directories:-----------------------------------------------------UserDir public_html

... and uncomment the block:

Page 13: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 12

--------------------<Directory /home/*/public_html>

...</Directory>

To allow cgi files to be executed under /home/httpd/cgi-bin:-----------------------------------------------------ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/"<Directory "/home/httpd/cgi-bin">

...Options ExecCGI Includes...

</Directory>

To allow server-parsed html:----------------------------AddType text/html .shtmlAddHandler server-parsed .shtml

* Test Apache: # apachectl restart

From another machine:$ netscape 130.191.247.69

* Unzip, untar, and install PHP:

$ ./configure --with-mysql-/usr/local/mysql--with-apxs=/usr/local/apache/bin/apxs--with-xml

$ make# make install

* Edit /etc/httpd/conf/httpd.conf to enable PHP:

LoadModule php3_module libexec/libphp3.so ^^^^^(or wherever PHP installed libphp3.so)

AddModule mod_php3.cAddType application/x-httpd-php3 .php3

* Install and tweak the php3.ini file:

# cp /usr/local/src/php-<vers>/php3.ini-dist /etc/httpd/conf/php3.ini

Edit the new file:------------------;safe_mode = Onshort_open_tag = Off;expose_php = Onerror_reporting = 15

* Test Apache/PHP:

Create test.php3 in /home/httpd/html:-------------------------------------

Page 14: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 13

<html><body><?php$myvar="Hello World!";echo $myvar;?></body></html>

# apachectl restart

In a web broswer, load http://130.191.247.69/test.php3

* COMPILE & INSTALL MOD_PERL *************** Edit /usr/local/src/apache-<vers>/src/Configuration:

--------------EXTRA_CFLAGS=`perl -MExtUtils::Embed -e ccopts`EXTRA_LIBS=`perl -MExtUtils::Embed -e ldopts`...AddModule modules/perl/libperl.aAddModule modules/php3/libphp3.a

# cp -r /usr/local/src/mod_perl-<vers>/src/modules/perl /usr/local/src/apache-<vers>/src/modules

# cd /usr/local/src/mod_perl-<vers># perl Makefile.PL DYNAMIC=1# make install

> Build Apache? -- NO

* This creates *all* necessary ___.pm files under /usr/lib/perl5/...

that where missing above.

* Edit httpd.conf to enable ePerl: --------------------------------

Perlrequire /home/httpd/html/startup.perlPerlModule Apache::ePerl<Files ~ ".+\.iphtml$"> Options +ExecCGI SetHandler perl-script PerlHandler Apache::ePerl</Files># optional:#<Perl>#$Apache::ePerl::Config->{'BeginDelimiter'} = '<?';#$Apache::ePerl::Config->{'EndDelimiter'} = '!>';#$Apache::ePerl::Config->{'CaseDelimiters'} = 0;#$Apache::ePerl::Config->{'ConvertEntities'} = 1;#</Perl>

* In /home/httpd/html create & make executable startup.perl ---------------------------------------------------------

#!/usr/bin/perluse strict;use Apache::Registry;use CGI;use DBI ();1;

Page 15: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 14

==============================================================Set up perms on user public_html dirs, files:

$ chmod 711 ~ditto, subdirs

$ chmod 644 *.* -- html files$ chmod 755 *.cgi -- cgi files

END OF DOCUMENT

Page 16: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 15

APPENDIX B

DEVELOPMENT DATABASE CREATION SCRIPT====================================

Script started on Sun Mar 11 01:04:36 2001

[engel@saass engel]$ mysql -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 164 to server version: 3.23.33

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

mysql> create database job_bank;Query OK, 1 row affected (0.00 sec)

mysql> use job_bank;Database changedmysql> show tables;Empty set (0.00 sec)

mysql> create table users -> (user_PK int not null auto_increment, -> last_name varchar(20) not null, -> first_name varchar(20), -> address varchar(40), -> state varchar(2), -> phone varchar(10), -> primary key (user_PK));Query OK, 0 rows affected (0.00 sec)

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

mysql> create table companies -> (company_PK int not null auto_increment, -> name varchar(50) not null, -> address varchar(40), -> state varchar(2), -> phone varchar(10), -> description varchar(200), -> primary key (company_PK));Query OK, 0 rows affected (0.00 sec)

mysql> create table contacts -> (contact_PK int not null auto_increment, -> name varchar(40) not null, -> phone vc archar(10), -> email varchar(40), -> company_FK int,

Page 17: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 16

-> primary key (contact_PK));Query OK, 0 rows affected (0.01 sec)

mysql> create table job_types -> (type_PK int not null auto_increment, -> type varchar(30), -> primary key (type_PK));Query OK, 0 rows affected (0.00 sec)

mysql> create table job_names -> (job_name_PK int not null auto_increment, -> job_name varchar(30), -> type_FK int, -> primary key (job_name_PK));Query OK, 0 rows affected (0.00 sec)

mysql> create table job_status -> (job_status_PK int not null auto_increment, -> job_status varchar(20), -> primary key (job_status_PK));Query OK, 0 rows affected (0.00 sec)

mysql> create table jobs_available -> (job_PK int not null auto_increment, -> company_FK int, -> job_name_FK int, -> job_status_FK int, -> duration varchar(30), -> submit_date date, -> expire_date date, -> description varchar(255), -> qualifications varchar(255), -> primary key (job_PK));Query OK, 0 rows affected (0.01 sec)

mysql> create table applications -> (app_PK int not null auto_increment, -> user_FK int, -> job_FK int, -> date date, -> primary key (app_PK));Query OK, 0 rows affected (0.00 sec)

mysql> show tables;+--------------------+| Tables_in_job_bank |+--------------------+| applications || companies || contacts || job_names || job_status || job_types || jobs_available || users |+--------------------+8 rows in set (0.01 sec)

Page 18: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 17

mysql> describe users;+------------+-------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+------------+-------------+------+-----+---------+----------------+| user_PK | int(11) | | PRI | NULL | auto_increment || last_name | varchar(20) | | | | || first_name | varchar(20) | YES | | NULL | || address | varchar(40) | YES | | NULL | || state | char(2) | YES | | NULL | || phone | varchar(10) | YES | | NULL | |+------------+-------------+------+-----+---------+----------------+6 rows in set (0.01 sec)

mysql> describe companies;+-------------+--------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+-------------+--------------+------+-----+---------+----------------+| company_PK | int(11) | | PRI | NULL | auto_increment || name | varchar(50) | | | | || address | varchar(40) | YES | | NULL | || state | char(2) | YES | | NULL | || phone | varchar(10) | YES | | NULL | || description | varchar(200) | YES | | NULL | |+-------------+--------------+------+-----+---------+----------------+6 rows in set (0.00 sec)

mysql> describe contacts;+------------+-------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+------------+-------------+------+-----+---------+----------------+| contact_PK | int(11) | | PRI | NULL | auto_increment || name | varchar(40) | | | | || phone | varchar(10) | YES | | NULL | || email | varchar(40) | YES | | NULL | || company_FK | int(11) | YES | | NULL | |+------------+-------------+------+-----+---------+----------------+5 rows in set (0.00 sec)

mysql> describe job_types;+---------+-------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+---------+-------------+------+-----+---------+----------------+| type_PK | int(11) | | PRI | NULL | auto_increment || type | varchar(30) | YES | | NULL | |+---------+-------------+------+-----+---------+----------------+2 rows in set (0.00 sec)

mysql> describe job-names;+-------------+-------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+-------------+-------------+------+-----+---------+----------------+| job_name_PK | int(11) | | PRI | NULL | auto_increment || job_name | varchar(30) | YES | | NULL | || type_FK | int(11) | YES | | NULL | |+-------------+-------------+------+-----+---------+----------------+3 rows in set (0.01 sec)

Page 19: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 18

mysql> describe job_status;+---------------+-------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+---------------+-------------+------+-----+---------+----------------+| job_status_PK | int(11) | | PRI | NULL | auto_increment || job_status | varchar(20) | YES | | NULL | |+---------------+-------------+------+-----+---------+----------------+2 rows in set (0.00 sec)

mysql> describe jobs_available;+----------------+--------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+----------------+--------------+------+-----+---------+----------------+| job_PK | int(11) | | PRI | NULL | auto_increment || company_FK | int(11) | YES | | NULL | || job_name_FK | int(11) | YES | | NULL | || job_status_FK | int(11) | YES | | NULL | || duration | varchar(30) | YES | | NULL | || submit_date | date | YES | | NULL | || expire_date | date | YES | | NULL | || description | varchar(255) | YES | | NULL | || qualifications | varchar(255) | YES | | NULL | |+----------------+--------------+------+-----+---------+----------------+9 rows in set (0.00 sec)

mysql> describe applications;+---------+---------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+---------+---------+------+-----+---------+----------------+| app_PK | int(11) | | PRI | NULL | auto_increment || user_FK | int(11) | YES | | NULL | || job_FK | int(11) | YES | | NULL | || date | date | YES | | NULL | |+---------+---------+------+-----+---------+----------------+4 rows in set (0.01 sec)

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

Database changedmysql> show tables;+-----------------+

Page 20: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 19

| Tables_in_mysql |+-----------------+| columns_priv || db || func || host || tables_priv || user |+-----------------+6 rows in set (0.00 sec)

mysql> insert into user -> (host) -> values ('%');Query OK, 1 row affected (0.00 sec)

mysql> select * from user -> where user=''\G*************************** 1. row *************************** Host: % User: Password: Select_priv: N Insert_priv: N Update_priv: N Delete_priv: N Create_priv: N Drop_priv: N Reload_priv: N Shutdown_priv: N Process_priv: N File_priv: N Grant_priv: NReferences_priv: N Index_priv: N Alter_priv: N1 row in set (0.00 sec)

mysql> insert into db -> (host,db) -> values ('%','job_bank');Query OK, 1 row affected (0.00 sec)

mysql> select * from db\G*************************** 1. row *************************** Host: % Db: job_bank User: Select_priv: N Insert_priv: N Update_priv: N Delete_priv: N Create_priv: N Drop_priv: N Grant_priv: NReferences_priv: N Index_priv: N

Page 21: Building and Administering a Web-Database Server (Linux ....doc

Web Database Administration -- 20

Alter_priv: N1 row in set (0.00 sec)

mysql> grant select,insert,update,delete,references,index -> on job_bank.* -> to '%';Query OK, 0 rows affected (0.01 sec)

mysql> select * from db\G*************************** 1. row *************************** Host: % Db: job_bank User: Select_priv: Y Insert_priv: Y Update_priv: Y Delete_priv: Y Create_priv: N Drop_priv: N Grant_priv: NReferences_priv: Y Index_priv: Y Alter_priv: N1 row in set (0.00 sec)

mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)

mysql> \qBye[engel@saass engel]$ Script done on Sun Mar 11 02:01:51 2001