MySQL Configuration

Introduction

MySQL is a multithreaded, multi-user SQL database management system (DBMS) that see wide use in the Linux environment (amongst others). I initially installed it in order to support Zoneminder.

For a general definition see: http://en.wikipedia.org/wiki/MySQL, but more comprehensive information is available from the offical site at http://www.mysql.com/.

MySQL was required in order to support the ZoneMinder application so that remote management and control of a suite of WebCams from the Linux server could be carried out. For details about the installation and configuration of ZoneMinder to use this, and other Webcams, see: ZoneMinder on the Linux Web-server. In fact the ZoneMinder configuration procedure includes setting up MySQL as part of the Zoneminder process.

The following guidance might be useful in helping to configure MySQL on an Apache Web-server running on Linux.

My MySQL Server Configuration

Create the necessary user and group in the system configuration files (using the usual groupadd and adduser facilities):

[root@host]# grep mysql /etc/passwd
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
[root@host]# grep mysql /etc/group
mysql:x:27:
[root@host]# 

Then typically just follow the standard installation procedure available from the download site.

Secure the root password: typically use the following to change the configuration off the defaults:

[root@99host]# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!
[root@host]#

To use from the Apache web-server ensure that the /etc/httpd/conf.d/auth_mysql.conf configuration file, is correctly configured.

===== auth_mysql.conf fragment =====

# mod_auth_mysql can be used to limit access to documents by checking
# data in a MySQL database.
#

LoadModule mysql_auth_module modules/mod_auth_mysql.so

#
# Other details as appropriate to the directories used by the web-server
# ...
#
=====

General Links

For general links to useful references when setting up MySQL see: Apache resources on the Internet.

The following general links are useful references when setting up MySQL:


URLSummary/Description
http://www.weberdev.com/ViewArticle/How-TO-Install-PHP%2C-Apache-and-MySQL-on-Linux-or-Unix How to Install PHP, Apache and MySQL on Linux or Unix
http://www.php-mysql-tutorial.com/ PHP / MySQL tutorial
http://www.digilife.be/quickreferences/quickrefs.htm Various quick references (such as PHP, MyQSQL, UNIX, etc)
http://www.freewebmasterhelp.com/tutorials/phpmysql/7 PHP/MySQL tutorial (complete 8 part process to set up a form accessing a MyQSL database)
http://www.wellho.net/solutions/mysql-interfacing-applications-to-a-mysql-database-engine.html Interfacing to MySQL
http://www.apache-php-mysql.com/ Apache PHP MySQL
http://www.mysql-apache-php.com/ Quick Linux Server Installation