MySQL/MariaDB Troubleshooting¶
Replication-specific failures are covered separately in Replication: Replication-Specific Troubleshooting — this page covers everything else.
ERROR 1050 (42S01): Table 'x' already exists¶
Usually surfaces when re-running a schema import that partially succeeded before. Check what's actually open/locked before assuming it's a stale leftover table:
SHOW PROCESSLIST;
SHOW FULL PROCESSLIST;
SHOW GLOBAL STATUS LIKE '%open%';
ps -ef | grep -i mysql
cat /proc/<pid>/limits
If the table genuinely shouldn't exist, drop it and re-run the import; if something else is actively using it, investigate that first rather than dropping data out from under a live process.
Purging Binary Log Files¶
Binlogs can consume a lot of disk over time if never rotated out. Check current usage, then purge up to (not including) a chosen file:
SHOW BINARY LOGS;
PURGE BINARY LOGS TO 'mysql-bin.000119';
SHOW BINARY LOGS; -- confirm the earlier files are gone
Prefer this over manually deleting binlog files from disk — PURGE BINARY LOGS keeps MySQL's own index in sync, whereas deleting files directly will leave it referencing files that no longer exist. For ongoing housekeeping rather than one-off cleanup, set expire_logs_days (or binlog_expire_logs_seconds on newer versions) in my.cnf instead of purging manually each time.
Reading Binary Log Contents¶
mysqlbinlog logfile > readable_output.sql
Connection / Configuration Issues¶
ERROR 1040: Too many connections¶
Raise max_connections in my.cnf, but also check whether something is leaking connections rather than just needing a higher ceiling — a steadily climbing Threads_connected with no corresponding application load growth points at a leak, not a capacity problem.
Connections refused despite the server being up¶
Check for a bind-address = 127.0.0.1 (or similar restrictive) line in my.cnf — this is a common and easy-to-miss cause of "the server is running but nothing can connect remotely."
ERROR 1698 (28000): Access denied for user 'root'@'localhost'¶
On distros where the local root account uses socket-based authentication (unix_socket/auth_socket), a password reset via UPDATE mysql.user may not change anything, because the plugin never checks the password field at all. See Administration: If You Can Already Get a Root Shell Without a Password for the actual fix.
Corrupted/Fragmented Tables¶
Covered in more depth in Administration: Table Maintenance — CHECK TABLE/REPAIR TABLE/mysqlcheck are the relevant tools, and apply specifically to MyISAM tables.
OS/MySQL Error Code Reference¶
Look up any numeric error code directly:
perror 113
# OS error code 113: No route to host
Frequently seen codes and what they usually mean¶
| Code | Meaning | Typical cause |
|---|---|---|
| 1 | Operation not permitted | Filesystem permissions on the data directory or a config file |
| 2 | No such file or directory | Wrong datadir/socket path in config |
| 13 | Permission denied | Data directory or socket not owned by the mysql user |
| 17 | File exists | Re-running an install/init step that already ran |
| 28 | No space left on device | Disk full — often binlogs; see Purging Binary Log Files above |
| 98 | Address already in use | Another process (or another instance) already bound to the port; see Multiple Instances if that's intentional |
| 110 | Connection timed out | Network path or firewall between client and server |
| 111 | Connection refused | Nothing listening on that port — check the service is actually running and bind-address |
| 112 | Host is down | Target host unreachable at the network level |
| 113 | No route to host | Routing/firewall issue — check /etc/hosts and network config, not just MySQL config |
MySQL-specific error codes (126–152)¶
Mostly legacy MyISAM storage-layer errors:
| Code | Meaning |
|---|---|
| 126 | Index file is crashed |
| 127 | Record file is crashed |
| 128 | Out of memory |
| 130 | Incorrect file format |
| 134 | Record was already deleted (or record file crashed) |
| 144 | Table is crashed and last repair failed |
| 145 | Table was marked as crashed and should be repaired |
| 146 | Lock timed out; retry the transaction |
| 149 | Deadlock detected; retry the transaction |
| 150 | Foreign key constraint is incorrectly formed |
| 151 | Cannot add a child row (foreign key violation on insert) |
| 152 | Cannot delete a parent row (foreign key violation on delete) |
For 144/145, see Administration: Table Maintenance.
Related¶
- Replication — replication-specific error handling
- Administration — the security/account context behind several errors above