INLS 183 Project 7: mysql-3.22.32

Introduction to MySQL

MySQL is database management software that runs on a number of platforms including the various Unixes, Linux, and Win32. It is one of several widely used and robust open source software programs (including Apache, PHP, Samba, etc) that have gained recent popularity on the coattails of Linux’s success. As Unix and Linux command a majority share of servers on the Internet, it’s not a surprise that MySQL is used widely as the database end of many a web-database application. I hope to explore web-database connectivity in some of my later installations.

MySQL is remarkably well-documented. Further information can be acquired at their website, www.mysql.com.

MySQL Installation

I began by downloading the most recent and stable MySQL source package (3.22.32) from one of MySQL’s mirror sites:

# lynx http://mysql.venoma.org/Downloads/MySQL-3.22/mysql-3.22.32.tar.gz

For the installation process, I followed MySQL's instructions pretty closely. First, I detarred and decompressed the package:

# tar zxf mysql-3.22.32.tar.gz

MySQL requires its own user and group for security reasons, so I executed the following commands:

# groupadd mysql
# useradd -g mysql mysql

Next came the familiar step of configuring the package, with the destination directory (prefix) as /usr/local/mysql:

# ./configure --prefix=/usr/local/mysql

Everything appeared to be going smoothly until the configure process dropped out with the following lines of output:

...
checking for tgetent in -lncurses... no
checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for termcap functions library... configure: error: No curses/termcap library found
#

As I was not intimately familiar with that particular error message, I employed a strategy that has saved me many times in the past: I searched Google for a similar complaint. The first page that Google pulled up was a MySQL message group posting describing my problem exactly. I wasn’t alone. The next page Google found was the response to that question, which contained this solution:

Sure, just install ncurses and termcap libs, or biuld MySQL without clients.

Ok, so I figured I’d go find the ncurses and termcap RPMs to get my system up to speed. I found the appropriate RPMs for RedHat 6.2 using rpmfind.net, and I tried to install them:

# rpm -ivh *
package ncurses-5.0-11 is already installed
package termcap-10.2.7-9 is already installed
#

That wasn’t too promising. Using the rpm -qa | grep “package name” command, I discovered that indeed they were already installed. Errr. So I went back to Google and read further down the list of pages, eventually coming upon a very long mysql message group archive. Searching through it, I again found a complaint similar to my situation. This time the response just below it, had this to say:

Do you have ncurses-devel installed? Its the development stuff its looking for... I had the same problem on the SparcLinux version I am playing with at present. Though I haven't yet fixed it cos I ran out of time, I'm pretty sure thats what it'll be :-)

I downloaded the ncurses-devel package after finding it via rpmfind.net, and it installed smoothly:

# rpm -ivh ncurses-devel-5.0-11.i386.rpm
ncurses-devel               ##################################################
#

Again, I tried  “./configure --prefix=/usr/local/mysql” and it finished successfully. Then came the familiar make steps:

# make
# make install

Once MySQL was installed, the instructions had me run the following script:

# scripts/mysql_install_db

And the file/group ownership of MySQL in /usr/local/mysql needed to be assigned to the MySQL user/group:

# chown -R mysql.mysql /usr/local/mysql

Finally I executed the last step, which starts MySQL running just like any daemon/server process:

# /usr/local/mysql/bin/safe_mysqld --user=mysql &

I also put this line in my rc.local file to ensure that MySQL would be restarted if the system needed to be rebooted.

Finally, I needed to set up a password for MySQL’s root user (which is different than the system’s root user).

# /usr/local/mysql/bin/mysqladmin -u root password 'type password here'

Having completed all of the previous steps, MySQL was configured, running, and ready to be tested.

MySQL in Action

I’m familiar with SQL and databases in general (primarily MS Access), so I decided to see if I could navigate MySQL just enough to see that it was working properly. To begin, I logged in to MySQL:

# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.22.32

Type 'help' for help.

mysql>

This opened a “mysql shell” that I could use to interact with the program. First I tried to view the generic mysql database that holds information about MySQL users and permissions:

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

Next I entered a command to show the mysql database tables:

mysql> show tables;
+-----------------+
| Tables in mysql |
+-----------------+
| columns_priv    |
| db              |
| func            |
| host            |
| tables_priv     |
| user            |
+-----------------+
6 rows in set (0.00 sec)

Though ending every command with a semicolon took some getting used to, I got pretty good at navigating the tables, a process I had taken for granted in my experience with Microsoft Access’s GUI.

Using MySQL's language reference, I decided to create my own test database, with a table listing my friends' names.

I started by creating the database:

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

Next, I switched to the new database and checked to see if it contained anything. It didn’t.

mysql> use justin;
Database changed
mysql> show tables;
Empty set (0.00 sec)

The process of creating a table with fields defined took a few tries before I got the syntax right:

mysql> create table friends (friendsID INT, firstName TEXT)

Still hoping for some visual gratification, I tried to look at the friends table, which of course contained no records:

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

Finally I was at the point where I could enter data:

mysql> INSERT INTO friends (friendsID,firstName) VALUES(1,’jackie’);

This time, I got my visual gratification:

mysql> select * from friends;
+-----------+-----------+
| friendsID | firstName |
+-----------+-----------+
|         1 | jackie    |
+-----------+-----------+
1 row in set (0.00 sec)

At this point I declared MySQL a success. However, I already had my sights set on getting this information on the web, with both the ability to view the contents of a table, and to add to the table.

INLS 183 Project 7: Mysql-3.22.32 script file