MySQL-4.0.15

Introduction to MySQL

MySQL is a widely used and fast SQL database server. It is a client/server implementation that consists of a server daemon and many different client programs and libraries.

Package information

MySQL dependencies

Installation of MySQL

For security reasons, running the server as an unprivileged user and group is strongly encouraged:

groupadd mysql &&
useradd -c mysql -d /dev/null -g mysql -s /bin/false mysql

Build and install MySQL by running the following commands:

cp configure configure.old &&
sed -e "s%mysql-test/Makefile%%" -e "s% mysql-test%%" configure.old > configure &&
./configure --prefix=/usr \
            --sysconfdir=/etc \
            --libexecdir=/usr/sbin \
            --localstatedir=/var/lib/mysql \
            --enable-thread-safe-client \
            --enable-local-infile \
            --without-debug \
            --without-bench &&
make &&
make install

Command explanations

sed -e "s%mysql-test/Makefile%%" -e "s% mysql-test%%" configure.old > configure: This sed is used to disable the mysql test suite.

Configuring MySQL

Config files

/etc/my.cnf, ~/.my.cnf

Configuration Information

There are several default configurations file available in /usr/share/mysql which you can use.

cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

We can now install a database and change the ownership to the unprivileged user and group.

mysql_install_db
chown -R mysql:mysql /var/lib/mysql

Further configuration requires that the mysql server be running:

mysqld_safe --user=mysql 2>&1 >/dev/null &

A default installation does not setup a password for the administrator. So here we will login and set one. We strongly suggest changing 'new-password' to your own.

mysql -uroot mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.23.51-log

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

mysql> UPDATE user SET password=password('new-password') WHERE user='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> EXIT;
bye

Now that we are done with the configuration of the server, we can shut it down.

kill `pidof -x mysqld_safe mysqld`

MySQL init.d script

To automate the running of MySQL, use the following command to create the init.d script:

cat > /etc/rc.d/init.d/mysql << "EOF"
#!/bin/bash
# Begin $rc_base/init.d/

# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans  - gerard@linuxfromscratch.org

source /etc/sysconfig/rc
source $rc_functions

case "$1" in
        start)
                echo "Starting MySQL daemon..."
                /usr/bin/mysqld_safe --user=mysql 2>&1 >/dev/null &
                evaluate_retval
                ;;

        stop)
                echo "Stopping MySQL daemon..."
                killproc mysqld
                ;;

        restart)
                $0 stop
                sleep 1
                $0 start
                ;;

        status)
                statusproc /usr/sbin/mysqld
                ;;

        *)
                echo "Usage: $0 {start|stop|restart|status}"
                exit 1
                ;;
esac

# End $rc_base/init.d/
EOF
chmod 755 /etc/rc.d/init.d/mysql

Create the symbolic links to this file in the relevant rc.d directory with the following commands:

cd /etc/rc.d/init.d &&
ln -sf ../init.d/mysql ../rc0.d/K26mysql &&
ln -sf ../init.d/mysql ../rc1.d/K26mysql &&
ln -sf ../init.d/mysql ../rc2.d/K26mysql &&
ln -sf ../init.d/mysql ../rc3.d/S34mysql &&
ln -sf ../init.d/mysql ../rc4.d/S34mysql &&
ln -sf ../init.d/mysql ../rc5.d/S34mysql &&
ln -sf ../init.d/mysql ../rc6.d/K26mysql

Contents

The MySQL package contains comp_err, isamchk, isamlog, msql2mysql, my_print_defaults, myisamchk, myisamlog, myisampack, mysql, mysql_config, mysql_convert_table_format, mysql_explain_log, mysql_find_rows, mysql_fix_extensions, mysql_fix_privilege_tables, mysql_install, mysql_install_db, mysql_secure_installation, mysql_setpermission, mysql_tableinfo, mysql_waitpid, mysql_zap, mysqlacess, mysqladmin, mysqlbinlog, mysqlbug, mysqlcheck, mysqld, mysqld_multi, mysqld_safe, mysqldump, mysqldumpslow, mysqlhotcopy, mysqlimport, mysqlmanager-pwgen, mysqlmanagerc, mysqlshow, mysqltest, pack_isam, perror, replace, resolve_stack_dump, resolveip, libdbug, libheap, libmerge, libmyisam, libmyisammrg, libmysqlclient, libmystrings, libmysys, libnisam and libvio.

Description

A package listing would be several pages long, we suggest consulting the MySQL documentation for full details, instead.

Certain MySQL support programs may require the Perl DBI modules to be installed to function properly.