---
title: "Installing AMXBans (MySQL Ban System) Step by Step"
excerpt: "Move CS 1.6 bans from flat files into MySQL with AMXBans: create the database, import the schema, configure the SQL file, load the plugins, and avoid the admin-system conflicts."
category: "administration"
tags: "amxbans, mysql"
image: ""
read_time: "9 min read"
---
<p>AMXBans replaces the flat-file <a href="/tutorials/amx-ban-commands">amx_ban</a> workflow with a MySQL-backed one: bans live in a database, a web panel manages them, and a fleet of servers can share one ban list. That is its whole appeal — one ban propagates everywhere and non-technical staff manage it from a browser. The trade-off is more moving parts. This walks the install in the order that avoids the usual conflicts.</p>
<h2>1. Prerequisites</h2>
<ul>
<li>A working AMX Mod X install (1.9 recommended) on <a href="/tutorials/install-rehlds-on-linux">ReHLDS</a> or HLDS.</li>
<li>The MySQL / <code>sqlx</code> module enabled — AMXBans is useless without it. See <a href="/tutorials/install-mysql-module-amxx">installing the MySQL module</a>.</li>
<li>A reachable MySQL/MariaDB server and a database you can create tables in.</li>
<li>The AMXBans package for your AMXX branch. Match the AMXBans version to your AMXX version; a mismatch is the top cause of load failures.</li>
</ul>
<h2>2. Create the database and user</h2>
<pre>CREATE DATABASE amxbans CHARACTER SET utf8;
CREATE USER 'amxbans'@'%' IDENTIFIED BY 'a-long-password';
GRANT ALL PRIVILEGES ON amxbans.* TO 'amxbans'@'%';
FLUSH PRIVILEGES;</pre>
<p>If MySQL runs on the same box as the game server, scope the host to <code>'localhost'</code> instead of <code>'%'</code> — do not expose the database more widely than you need.</p>
<h2>3. Import the schema</h2>
<p>The AMXBans package ships a <code>.sql</code> schema file. Import it into the database you just made:</p>
<pre>mysql -u amxbans -p amxbans < amxbans.sql</pre>
<p>This creates the ban, admin and server tables the plugins and the web panel both read. Use the SQL file from your downloaded package — do not hand-write the schema, and do not import one from a different AMXBans version.</p>
<h2>4. Install the plugin and module files</h2>
<p>Copy the AMXBans plugins into <code>addons/amxmodx/plugins/</code> and add them to <code>addons/amxmodx/configs/plugins.ini</code>. AMXBans is split into a core plugin plus a main plugin; add them in the order the package README specifies. Copy any bundled config files into <code>addons/amxmodx/configs/</code> as directed.</p>
<pre>; plugins.ini (order per the AMXBans readme)
amxbans_core.amxx
amxbans_main.amxx</pre>
<p>Exact filenames vary by AMXBans release — use the ones in your package rather than assuming. If a plugin is missing from <code>plugins.ini</code> it simply never runs, with no error.</p>
<h2>5. Configure the SQL connection</h2>
<p>AMXBans reads its database credentials from a config file in <code>addons/amxmodx/configs/</code> (the package documents the exact name). Fill in host, user, password, database and the ban-prefix/server id:</p>
<pre>host 127.0.0.1
user amxbans
pass a-long-password
db amxbans</pre>
<p>Keep this file readable only by the server account — it holds a database password. Set the server id so the panel can tell your servers apart if you run more than one.</p>
<h2>6. Resolve the admin-system conflict</h2>
<p>This is the step people miss. AMXBans can manage admins from its own database tables. If you let it, you must stop the stock SQL admin plugin from fighting it: do not also run <code>admin_sql.amxx</code> pointed at a different table, and decide whether admins come from AMXBans' tables or from <a href="/tutorials/users-ini-explained">users.ini</a> — not both. Running two admin sources produces flicker where a player is an admin one map and not the next. Pick one; for most installs, let AMXBans own bans while users.ini still owns admin flags is the simplest split, following the package's guidance for your version.</p>
<h2>7. Load and test</h2>
<pre>amxx reload
changelevel de_dust2</pre>
<p>A map change is the clean way to load new plugins. Watch the console at startup for AMXBans connecting to MySQL.</p>
<h2>Common errors</h2>
<ul>
<li><strong><code>Failed to load module: mysql/sqlx</code></strong> — the database module is not enabled in <code>modules.ini</code>. Fix that first via <a href="/tutorials/install-mysql-module-amxx">the MySQL module guide</a>; nothing else will work until it loads.</li>
<li><strong>AMXBans logs <code>Can't connect to MySQL</code></strong> — wrong host/user/password, or the DB user is not allowed from the game server's IP. Test the same credentials with the <code>mysql</code> CLI from the game box.</li>
<li><strong>Plugin shows <code>bad load</code></strong> — AMXBans version does not match your AMXX version. Download the build for your branch.</li>
<li><strong>Admins flicker on/off between maps</strong> — you are running two admin sources (AMXBans tables and admin_sql). Disable one, per step 6.</li>
<li><strong>Bans not appearing in the web panel</strong> — the panel points at a different database than the plugins, or the server id does not match. Confirm both use the same DB and id.</li>
</ul>
<h2>Verification</h2>
<p>Ban a test SteamID in-game, then query the database directly:</p>
<pre>mysql -u amxbans -p amxbans -e "SELECT player_nick, player_id, ban_length FROM amx_bans ORDER BY ban_created DESC LIMIT 5;"</pre>
<p>(Table and column names follow your imported schema.) The ban you just issued should be the top row, and the web panel should show the same entry. Have the banned account try to reconnect and confirm it is refused. When an in-game ban, the database row, and the panel all agree, AMXBans is installed correctly.</p>