Private
Protection
Special Offers
Catalog
Auto donation
The MySQL or MariaDB service crashes on startup and there is no fresh dump? Here is what to do step by step: save the files, start the server in recovery mode, take a dump and move the data to a clean installation.
Before you try to repair the database, read the error log: quite often the server fails to start for reasons that have nothing to do with damaged data.
# Linux
sudo journalctl -u mariadb -n 100 --no-pager # for MySQL: -u mysql
sudo tail -n 100 /var/log/mysql/error.log
df -h # is the disk full?On Windows the error log is a file with the .err extension in the data directory (usually named after the computer). Service messages also appear in Event Viewer under Windows Logs, Application.
Causes you can fix without any recovery:
my.cnf or my.ini after editing;mysql user).If the log reports InnoDB corruption (Database page corruption, Assertion failure, page read errors), go on to the next steps.
The database server must be stopped: a file copy of a running server is inconsistent. Copy the whole data directory, not just the folder of your server database: InnoDB tables also need the shared ibdata1 file, the ib_logfile* logs (the #innodb_redo directory in MySQL 8), the undo files and, in MySQL 8, the mysql.ibd data dictionary.
| System | Default data directory |
|---|---|
| Debian, Ubuntu (MariaDB and MySQL) | /var/lib/mysql |
| Windows, MySQL 8 | C:\ProgramData\MySQL\MySQL Server 8.0\Data |
| Windows, MariaDB | C:\Program Files\MariaDB 10.11\data (use your version number) |
| Windows XP, MySQL 5.1 (old installations) | C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\data |
The exact path is set by the datadir option in the config. The ProgramData folder is hidden on Windows: turn on hidden items in the File Explorer View menu or simply paste the path into the address bar. If the disk is full, copy to another disk or straight to another machine.
# Linux
sudo systemctl stop mariadb # or mysql
sudo cp -a /var/lib/mysql /root/mysql-data-$(date +%F)
# or straight into an archive:
sudo tar -czf /root/mysql-data-$(date +%F).tar.gz -C /var/lib mysql:: Windows, Command Prompt run as administrator
net stop MySQL80
robocopy "C:\ProgramData\MySQL\MySQL Server 8.0\Data" "D:\mysql-data-backup" /EThe Windows service name may differ (MySQL80, MySQL, MariaDB): check it in the Services console (services.msc).
The innodb_force_recovery option makes InnoDB start while skipping some checks and recovery operations. The goal is not to repair the database but to get the server running just long enough to take a dump. Add the option to the [mysqld] section of the config and start the service:
[mysqld]
innodb_force_recovery = 1| Level | What is skipped | Risk |
|---|---|---|
| 1 | The server keeps running even if it finds corrupt pages and tries to skip broken records and pages when reading | Safe |
| 2 | InnoDB background threads (the master thread and purge) do not start | Safe |
| 3 | Unfinished transactions are not rolled back after a crash | Relatively safe |
| 4 | No insert buffer merge, no table statistics | Can permanently corrupt data files |
| 5 | Undo logs are not read: unfinished transactions are treated as committed | Can permanently corrupt data files |
| 6 | The redo log is not applied at startup | Can permanently corrupt data files |
While the server is running in recovery mode, export the server databases to an SQL file. In MariaDB the tool is called mariadb-dump (the old mysqldump name usually works too); in MySQL it is mysqldump. Use your own database name; if your pack has separate login and game server databases, list them after --databases separated by spaces.
mysqldump -u root -p --routines --events --databases l2jdb > l2jdb_dump.sql
# MariaDB:
mariadb-dump -u root -p --routines --events --databases l2jdb > l2jdb_dump.sqlCheck the result: the file must not be empty, and its last line should start with -- Dump completed (run tail -n 1 l2jdb_dump.sql).
If the dump stops at a particular table, export everything else without it and try to save the problem table separately:
mysqldump -u root -p --routines --events --databases l2jdb \
--ignore-table=l2jdb.broken_table > l2jdb_without_broken.sql
mysqldump -u root -p l2jdb broken_table > broken_table.sqlMyISAM tables (common in older packs) can often be repaired with mysqlcheck -u root -p --repair l2jdb. This command does not repair InnoDB tables: their data can only be saved with a dump.
bin folder, for example C:\Program Files\MySQL\MySQL Server 8.0\bin, or use the full path to the program. In Windows PowerShell use the --result-file=l2jdb_dump.sql option instead of redirecting output to a file: redirection saves the file as UTF-16, and such a dump will not load later.Now start the server on a clean data directory and load the dump into it. Do not delete the damaged directory, rename it: it may still come in handy.
innodb_force_recovery from the config.mysql system database, which we did not transfer.sudo systemctl stop mariadb
sudo mv /var/lib/mysql /var/lib/mysql.broken
sudo mkdir /var/lib/mysql
sudo chown mysql:mysql /var/lib/mysql
sudo mariadb-install-db --user=mysql --datadir=/var/lib/mysql
# for MySQL 8 use this instead of the previous line:
# sudo mysqld --initialize-insecure --user=mysql
sudo systemctl start mariadbsudo mariadb < l2jdb_dump.sql # for MySQL: sudo mysql < l2jdb_dump.sqlCREATE USER 'l2j'@'localhost' IDENTIFIED BY 'password_from_server_config';
GRANT ALL PRIVILEGES ON l2jdb.* TO 'l2j'@'localhost';Take the login, password and database name from your pack's database connection config. After --initialize-insecure the MySQL root password is empty, so set one right away with ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';.
Here is an example of a daily backup on Linux. Create the script /usr/local/bin/l2-backup.sh (for MySQL replace mariadb-dump with mysqldump):
#!/bin/bash
set -euo pipefail
DIR=/var/backups/l2
mkdir -p "$DIR"
mariadb-dump --single-transaction --routines --events --databases l2jdb \
| gzip > "$DIR/l2jdb_$(date +%F_%H-%M).sql.gz"
# delete copies older than 14 days
find "$DIR" -name 'l2jdb_*.sql.gz' -mtime +14 -deleteMake the script executable and add it to cron (sudo crontab -e):
sudo chmod +x /usr/local/bin/l2-backup.sh
# crontab line: every day at 04:30
30 4 * * * /usr/local/bin/l2-backup.sh/root/.my.cnf (a [client] section, permissions 600) instead of putting the password on the command line. The --single-transaction option gives a consistent dump of InnoDB tables without stopping the server; if your pack has MyISAM tables, it is safer to take the dump while the game server is stopped.On Windows the same is done with Task Scheduler: create a task that runs a PowerShell script once a day, for example (the login and password go into a my.cnf file with a [client] section):
$d = Get-Date -Format 'yyyy-MM-dd'
$dump = 'C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqldump.exe'
& $dump --defaults-extra-file=C:\l2backup\my.cnf --single-transaction --routines --events --databases l2jdb "--result-file=D:\l2backup\l2jdb_$d.sql"More server maintenance tips are in the guide Linux for game server admins.
Published 14 November 2026
We help with the server pack, setup, protection and launch — one-off or on an ongoing basis.
Get L2‑Scripts news by email
And 5% off all studio services while you stay subscribed.
The discount is valid while you are subscribed: when ordering, tell the manager your subscription address on Telegram.
Search
News