Fix: AMXBans Doesn't Ban / No Rows Inserted in MySQL

July 2, 2025 Daemon666 8 min read 9 views

You run a ban through AMXBans, the player is kicked, but the web panel stays empty and SELECT * FROM amx_bans returns nothing. The ban lived only in engine memory and vanished on map change. AMXBans is a database ban system, so if no row is inserted, the plugin never reached MySQL. This walks the four links in that chain — module, credentials, load order, table names — in the order they break.

1. Confirm the MySQL module is running

AMXBans writes through the mysql module. If it is not loaded, every insert silently fails. Check at the console:

amxx modules

You want a line for mysql reading running. If it is missing, enable it in addons/amxmodx/configs/modules.ini and install it as in installing the MySQL module. No module, no rows — full stop.

2. Check the AMXBans SQL credentials

AMXBans keeps its own database config separate from other plugins, under addons/amxmodx/configs/amxbans/. Open the SQL config there and confirm every field:

SQL_HOST     "127.0.0.1"
SQL_USER     "csbans"
SQL_PASS     "..."
SQL_DB       "amxbans"
SQL_PREFIX   "amx"

A wrong host, password, or database name here is the single most common cause. Watch the AMXX log at map start for the connection result — a failure quotes the MySQL error verbatim, for example:

[MySQL] Error: Access denied for user 'csbans'@'localhost' (using password: YES)

or, when the account is not allowed from the server's address:

[MySQL] Error: Host '203.0.113.10' is not allowed to connect to this MySQL server

Fix the grant or the credentials until the log shows a clean connect. This is the same troubleshooting used when setting up the AMXBans web panel.

3. Verify plugin load order

AMXBans ships as several plugins and the core must initialise before the parts that use it. In plugins.ini the AMXBans block belongs together and amxbans_core.amxx must sit above amxbans_main.amxx:

amxbans_core.amxx
amxbans_main.amxx

If main loads first it has no database handle and bans go nowhere. The rules for ordering are in plugins.ini load order. Follow the full install in installing AMXBans if you are unsure which lines belong.

4. Match the table prefix to the database

The SQL_PREFIX value builds the real table names — prefix amx means amx_bans, amx_admins. If you imported the schema with one prefix and configured another, the plugin queries a table that does not exist and the insert errors out. Confirm the tables actually present:

SHOW TABLES;

and make the prefix in the config match what you see. A mismatched prefix produces "Table 'amxbans.amx_bans' doesn't exist" in the log.

5. Trace it end to end when the log is quiet

Sometimes the connection succeeds and the tables exist, yet bans still do not appear. When that happens, prove each stage in isolation. First, confirm AMXBans is genuinely the plugin handling the ban and not the stock admin.amxx ban path running in parallel — two ban systems fighting over the same command means your ban may have gone through the engine list instead of the database. Second, watch the AMXX log the moment you issue the ban, not just at map start; a query that fails at ban time prints its own MySQL error there. Third, run the same INSERT the plugin would run directly against the database as the configured user — if that fails by hand, the account lacks INSERT privilege on the table even though it can connect and read. Grant the missing privilege and the plugin's writes start landing.

Common errors

  • Player kicked but no DB row — the ban ran through the engine only. The module or the credentials failed; check the log from map start.
  • "Access denied for user" — wrong password, or the MySQL account lacks rights on that database. Regrant and retest.
  • "is not allowed to connect" — the grant is host-locked. Add a grant for the server's IP, or use 127.0.0.1 when DB and server share a box.
  • "Table ... doesn't exist" — prefix mismatch or the schema was never imported. Fix SQL_PREFIX or import the SQL.
  • Bans insert but reappear after unban — you cleared the engine list but not the row; unban through AMXBans, see how to unban a player.

Verification

Ban a test SteamID in-game, then query the table directly:

SELECT player_nick, player_id, ban_length FROM amx_bans ORDER BY ban_created DESC LIMIT 1;

The row must be present with the SteamID you banned. Refresh the web panel and confirm it shows there too. Finally change the map and reconnect the banned client — if the block survives the map change, the ban is genuinely in MySQL and AMXBans is authoritative again. If the row is still missing, the log from the last map start names the exact link that failed.

Contributors: Daemon666 ✦
Share: