Page Views

Network Views

 


Sponsor Links:



Mysql On A Raq 3 & Above

This is a HOWTO for installing MySQL on an x86-based Sun Cobalt RaQ or Qube server. MySQL is not used by the UI on any of these products, so replacing or installing it is not a big deal.

NOTE: This HOWTO is NOT for use on the MIPS-based products (Qube 2700, Qube 2, RaQ 1, RaQ 2). They need a compiler upgrade and some other stuff before you can build MySQL on them. Go here for the MIPS compiler upgrade and MySQL build information.

I designed this HOWTO so that you can just copy/paste each block of commands into your shell session and it will "just work" for you, thus avoiding typing (and typos) on your part. Text in red monospace is a literal Linux commandline, and should be typed or pasted exactly as written.

If you cut-and-paste these steps EXACTLY on a "stock" server, the procedure WILL work properly! Dozens of other people have followed these exact steps with no problem. If you have a problem, it's something you did. If you try typing the commands yourself instead of cut-and-paste, you run the risk of a typo, a missed step, etc.

NOTE: If the MySQL version number has changed, please substitute the most up-to-date stable version of MySQL for whatever is specified here.

ESTABLISH SHELL SESSION AS root

Use telnet or SSH to establish a shell session on the server.

REMOVE ANY OLDER VERSION OF MySQL

On a Qube 3, RaQ XTR, or RaQ 550 we need to remove the pre-installed version of MySQL first. It is installed via RPM, so just do:

rpm -qa | grep -i mysql

to get a list of all installed MySQL RPMs.

DANGER: IF YOUR MYSQL DATABASE ALREADY HAS
CONTENT IN IT, THE NEXT STEP WILL ERASE THAT DATA!

To actually uninstall MySQL do:

rpm -e mysql-filename.rpm

for each RPM file listed by the rpm -qa step above.

GET SOURCE CODE FOR MySQL

At the time of updating this the current version of MySQL is: 4.1.21

Make a "working" directory

mkdir -p /home/src
cd /home/src

Use the command-line browser lynx to visit www.mysql.com. Navigate to the Download section, select a mirror near you, and get the source code bundle for the latest MySQL version (source code is all the way at the bottom of the page).

Alternatively, if you know a direct mirror and version, you can use wget to pull the one file across:

wget http://downloads.mysql.com/archives/mysql-4.1/mysql-4.1.21.tar.gz
or
wget http://cobalt.webtrafficstats.com/downloads/mysql-4.1.21.tar.gz

(The mirror listed in the example is in California.)

Then "unpack" the source code:

tar zxvf mysql-3.23.56.tar.gz

This will leave you with a directory structure like this:

/home/src/mysql-3.23.56/

BUILD AND INSTALL MySQL

First, we create the group and user that "owns" MySQL. For security purposes, we don't want MySQL running as root on the system. To be able to easily identify MySQL processes in top or a ps list, we'll make a user and group named mysql:

groupadd mysql useradd -g mysql mysql

Now we'll change to the "working" directory where the source code is, and start building. The configure command has many options you can specify. I have listed some fairly common ones; if you'd like to see others, do:

./configure --help | less

to see them all. Read the documentation on the MySQL website for a more detailed explanation of each option.

cd /home/src/mysql-4.1.21
./configure \
--prefix=/home/mysql \
--localstatedir=/home/mysql/data \
--disable-maintainer-mode \
--with-mysqld-user=mysql \
--enable-large-files \
--without-comment \
--without-debug \
--without-bench

Now comes the long part, where the source code is actually compiled and then installed. Plan to get some coffee or take a break while this step runs. It could be 10-15 minutes or more, depending on your system's free memory, load average, etc.

make && make install

CONFIGURE AND START MySQL

MySQL is "installed" but we have a few more steps until it's actually "done" and ready to start. First run the script which actually sets up MySQL's internal database (named, oddly enough, mysql).

./scripts/mysql_install_db

Then we want to set the proper ownership for the MySQL directories and data files, so that only MySQL (and root) can do anything with them.

chown -R root:mysql /home/mysql
chown -R mysql:mysql /home/mysql/data

Now we have to tell the system where to find some of the dynamic libraries that MySQL will need to run. We use dynamic libraries instead of static to keep the memory usage of the MySQL program itself to a minimum.

echo "/home/mysql/lib/mysql" >> /etc/ld.so.conf ldconfig

Now we want to set up a startup script, which enables MySQL auto-start each time your server is restarted.

cp ./support-files/mysql.server /etc/rc.d/init.d/mysql.server
chmod +x /etc/rc.d/init.d/mysql.server
/sbin/chkconfig --level 3 mysql.server on

Then we set up symlinks for all the MySQL binaries, so they can be run from anyplace without having to include/specify long paths, etc.

cd /home/mysql/bin for file in *; do ln -s /home/mysql/bin/$file /usr/local/sbin/$file; done

Now we can start the MySQL server!

cd ~ /etc/rc.d/rc3.d/S90mysql.server start

Let's "test" it to see what version we're running now:

mysqladmin version

Now we'll set a new password for the MySQL root user (not the same as the system root user!)

mysqladmin -u root password new-password

(obviously, insert your own password instead of the "new-password" string!)

You're done! MySQL is now installed and running on your server.

TEST THE MySQL SERVER

To run a quick test, use the command line program mysql:

mysql -u root -p

and enter your new root user password when prompted. You will then see the mysql prompt:

mysql>

Create a new database:

mysql> create database foo;

You should see the result:

Query OK, 1 row affected (0.04 sec) mysql>

To exit from mysql enter \q:

mysql> \q Bye

MySQL TEST SECTION TO BE FINISHED LATER...