Nerdrium Home



Web Design

Case Mods





My Blog




Installing MySQL Database Software

by Michael Greifenkamp (February 20th, 2004)

After getting Apache installed, the next step for me to configure my new server was to install MySQL database software. I downloaded the Standard edition of 4.0.17 for x86 Linux from MySQL's website.

Again, I downloaded the gzipped file to my user directory on the server, and logged in as the superuser (root).

# su -l
(Enter your password to log in as root.)

# mkdir /home/installers/mysql
# mv /home/username/mysql*.gz /home/installers/mysql
# cd /home/installers/mysql
# gzip -d mysql*.gz
# tar xvf mysql*.tar
# mv mysql*i686 /usr/local
# cd /usr/local
# chown -R root:root mysql*
# ln -s mysql-standard-4.0.17-pc-linux-i686 mysql
# cd mysql
# scripts/mysql_install_db

The next thing to do is create a user and group "mysql." And then the most important part--changing the permissions so that the user mysql owns what it needs to in order to use the database software.

# useradd -m mysql
# passwd mysql

(Enter a new password for user mysql.)

# cd /usr/local/mysql
# chown mysql data
# chgrp mysql data
# cd data
# chown mysql *
# chgrp mysql *
# cd mysql
# chown mysql *
# chgrp mysql *

Now we can start up MySQL and make sure it is working properly:

# cd /usr/local/mysql
# bin/safe_mysqld &
# bin/mysqladmin ping

(It should reply "mysqld is alive.")

Next we need to set a root password.

# bin/mysqladmin -uroot password (type your password here)

Still with me? Okay, now let's test the installation, and finally, shut it down.

# bin/mysql -uroot -p
Enter password:
(Enter your password)
> use mysql;
> select * from db;
> quit;
# cd /usr/local/mysql/
# bin/mysqladmin -uroot -p shutdown
Enter password:
(Enter your password)

Piece of cake, eh? Just make sure you do the permissions properly. Now, to sum up:

# cd /usr/local/mysql
# bin/safe_mysqld &
# bin/mysqladmin -uroot -p ping
Enter password:
(Enter your password)
mysqld is alive
# bin/mysqladmin -uroot -p shutdown
Enter password:
(Enter your password)

Now I realize that this doesn't offer much in the way of how to actually *use* MySQL, but there is lots of very good documentation online. Have fun!

Next up, installing PHP...