Setting up Admin Mod with MySQL
To run Admin Mod in combination with a MySQL database you have to
setup the database and then configure Admin Mod to use it. The
information that Admin Mod can retrieve from a database is the
information normally kept in the files users.ini, models.ini, ips.ini,
wordlist.txt and plugins.ini. You can still use the files with the
MySQL version of Admin Mod. You can mix file and database operation
but the database tables, if specified, will take precedence. Data is
read only from tables or files, not both. If Admin Mod fails to read
data from the specified MySQL table it will fall back to using files.
Please read the manual first to understand how to set up Admin Mod in
general and what the configuration files are about and their contents.
MySQL database setup
====================
On your MySQL server you will have to set up a database to store the
data for Admin Mod to use. What name you give to the database and what
tables it contains is up to you. You can also have more fields in
tables than those described below. This document only describes the
maximum set of tables and columns necessary for a complete Admin Mod
setup. You can leave out tables which you don't need or add other
tables unrelated to Admin Mod. The names for the tables are also
free. The only thing which you cannot choose freely are the column
names. But we get to that later.
The database
------------
Let's start with the database. For this example we choose to call it
adminmod. You can choose another name. If you haven't created a
database, yet, do so now with the CREATE DATABASE command. Refer to
the MySQL manual for any details concerning MySQL commands and syntax.
mysql> CREATE DATABASE adminmod;
The users table
---------------
Next we create the table holding the admin users. We choose to call it
users. You can give it another name. The users table has three columns:
nick, pass and access. These columns correspond to the three fields for
entries in the file specifies by the users_file cvar. nick is the
nickname of the user, pass is his password and access his access
level.
mysql> CREATE TABLE users( nick VARCHAR(30) PRIMARY KEY NOT NULL,
--> pass VARCHAR(20), access INTEGER UNSIGED );
mysql> DESCRIBE users;
+--------+-------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------------+------+-----+---------+-------+
| nick | varchar(30) | | PRI | | |
| pass | varchar(20) | YES | | NULL | |
| access | int(10) unsigned | YES | | NULL | |
+--------+-------------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
The models table
----------------
The models table has two columns: nick and pass. These two columns
correspond to the fields in an entry of the file specified by the
models_file cvar. nick is the name of the model and pass is the
assigned password. We choose to call it models. You can choose a
different name.
mysql> CREATE TABLE models( nick VARCHAR(20) PRIMARY KEY NOT NULL,
--> pass VARCHAR(20) );
mysql> DESCRIBE models;
+--------+-------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------------+------+-----+---------+-------+
| nick | varchar(20) | | PRI | | |
| pass | varchar(20) | YES | | NULL | |
+--------+-------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
The ips table
-------------
The table to hold the IPs corresponds to the file specified by the
ips_file cvar and has only one column called ip. We choose to name the
table ips. You can give it a different name.
mysql> CREATE TABLE ips( ip VARCHAR(15) );
mysql> DESCRIBE ips;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| ip | varchar(15) | | | | |
+-------+-------------+------+-----+---------+-------+
1 row in set (0.01 sec)
The words table
---------------
The words table holds the words to be filtered from player chat. It
corresponds to the file specified by the words_file cvar and has only
one column called word. We choose to name the table words. You can
give it another name.
mysql> CREATE TABLE words ( word VARCHAR(30) );
mysql> DESCRIBE words;
+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| word | varchar(30) | | | | |
+---------+-------------+------+-----+---------+-------+
1 row in set (0.01 sec)
The plugins table
-----------------
This table lists the plugins to be used on the server. It has only one
column called plugin. It corresponds to the file specified by the
admin_plugins_file cvar. We choose to call it plugins. You can give it
another name.
mysql> CREATE TABLE plugins( plugin VARCHAR(30) );
mysql> DESCRIBE plugins;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| plugin | varchar(30) | | | | |
+----------+-------------+------+-----+---------+-------+
1 row in set (0.01 sec)
Admin Mod variables setup
=========================
To use Admin Mod with the database that you just set up you have to
tell it how to connect to the MySQL server and what database and
tables to use. Admin Mod provides you with a set of cvars to do
so. You set these cvars in the server.cfg file just like all the other
cvars.
Connecting to the MySQL server
------------------------------
To connect to the server you need to specify the address of the
server, the user to access it as and the password to use.
mysql_host
This variable specifies the address of the machine that the MySQL
server is running on. Examples:
mysql_host "192.168.2.1"
mysql_host "localhost"
mysql_host "some.machine.net"
mysql_user
This variable specifies the username under which Admin Mod should
connect to the MySQL server. Examples:
mysql_user "adminmod"
mysql_user "someclient"
mysql_pass
This variable specifies the password of the user to connect to the
MySQL server. Examples:
mysql_pass "somepass"
Retrieving data from tables
---------------------------
The following variables are used to specify which database and which
table to use. The format is "database.table". The list should be
self-explanatory. The examples use the database and table names which
were used in the examples above.
The table for admin users:
mysql_dbtable_users
E.g.:
mysql_dbtable_users "adminmod.users"
The table for models:
mysql_dbtable_models
E.g.:
mysql_dbtable_models "adminmod.models"
The table for IPs:
mysql_dbtable_ips
E.g.:
mysql_dbtable_ips "adminmod.ips"
The table for censored words:
mysql_dbtable_words
E.g.:
mysql_dbtable_words "adminmod.words"
The table for plugins:
mysql_dbtable_plugins
E.g.:
mysql_dbtable_plugins "adminmod.plugins"
You don't have to use all available tables. As an example you can
choose to only use the users and plugins tables from the database. The
reserved models will be read from a local file and you don't want to
use the IPs. That would result in the following setup:
modles_file "models.ini"
ips_file 0
mysql_dbtable_users "adminmod.users"
mysql_dbtable_plugins "adminmod.plugins"
It is a good idea to have users.ini and plugins.ini files, too. That
way Admin Mod can fall back to those files if it is unable to read
from the MySQL tables.