Please note the following is based upon installing and configuring MySQL 3.x and also some initial dabbling with 4.0.18.
These instructions are subject to revision following my own experiences with getting the stuff working.
As usual I suggest performing the following as the root user.
Google and download the source file mysql-4.0.18.tar.gz [12.8M] or its equivalent from the web.
Firstly create a user named mysql
with the adduser
command. Make them a part of the mysql
group. Use an empty password and a null shell (nologin):
Full name: mysql
Uid (Leave empty for default):
Login group [mysql]:
Login group is mysql. Invite mysql into other groups? :
Login class [default]:
Shell (sh csh tcsh bash nologin) [sh]: nologin
Home directory [/home/mysql]:
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:yes
Lock out account after creation? [no]:
OK? (yes/no): yes
Change to the directory where you downloaded the source and unpack the archive..
tar -zxvf mysql-4.0.18.tar.gz
Build and then run the configure script. This will create the Makefile needed to install the binary:
#Mysql Configure Script - mysqlscript.sh
./configure --prefix=/usr/local/mysql \
Next make the file executable and then run it, followed by the usual install routine..
chmod 755 mysqlscript.sh
in particular, can take a bit of time depending on your hardware. Go and have a coffee.
Once it's cooked, it's time to initialise the mysql database as the system user
Note it is important to run this as user mysql
as it allows the mysql user to start mysql
The above requires a successful hostname to IP Address mapping
. If the script finds a DNS Server in /etc/resolv.conf
, there must be a Host entry in the DNS Server's database to resolve the MySQL box's hostname, before it will work. If there's no DNS server, put an entry in /etc/hosts
The mysql_install_db script creates the data directory, the mysql database which holds all database privileges and the
test database which can be used to test MySQL. The script also creates privilege table entries for root accounts and
The accounts have no passwords initially. Briefly, these privileges allow the MySQL root user to do anything, and allow anybody to create or use databases with a name of test or starting with test_."
Next, prepare the MySQL config file, my.cnf
cp my-medium.cnf /etc/my.cnf
so the server/client can find the socket. Look for the lines under mysql server and mysql
client and add the following line. Note that the install may have done this already..
(check, may already be set)
Secure the server by making the following changes to file permissions and ownership. The server cannot be run securely without making these changes..
chown -R mysql /usr/local/mysql
(-R = all the files in dir)
chgrp -R mysql /usr/local/mysql
chmod 700 /usr/local/mysql/var
(where the logs live, read only by owner)
Link all useful binaries to /usr/local/sbin
ln -s /usr/local/mysql/bin/mysql /usr/local/sbin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /usr/local/sbin/mysqladmin
ln -s /usr/local/mysql/bin/mysqld_safe /usr/local/sbin/mysqld_safe
The /usr/local/sbin directory sits in the system path. By creating symlinks to the MySQL binary, the executable can be run from anywhere within the Unix file system, without having to type the whole path.
Finally, start the mysql service as the system user mysql
mysqld_safe --user=mysql &
(hit enter twice to get back to the prompt)
Previous versions of MySQL allowed the service to be started using the system user root, thus:
mysqld_safe --user=root &
However it is a bonza security risk to start mysql as the system root user and definitely not recommended unless you like to live dangerously..
If you are really forgetful, like my amnesic chum Brad who keeps forgetting to type the ampersand, then the process will run in the foreground and won't let you do anything else - d'oh! Easiest thing is to log in again as another session (ALT F2) and kill the process and restart it properly.
To test the server Run:
With a bit of luck you'll see something resembling a working MySQL.
To make MySQL start from boot, add the following line to /etc/rc.local
/usr/local/mysql/bin/mysqld_safe --user=mysql &
Note that the MySQL service is run as this special user mysql
and NOT as the system user called root
. Running the service with the root
user causes possible security risks.