Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

MySQL Basic Troubleshooting Guide: Service, Port 3306, Logs, and Crash Repair

mysql-troubleshooting

Originally published on 2013-05-15; fully revised and updated.

MySQL incidents are often a mix of service state, configuration mistakes, port conflicts, and storage pressure. This guide gives a practical troubleshooting sequence for DevOps and operations teams, with command examples you can run on Linux hosts and notes for legacy setups still using older init scripts.

Fast triage workflow

Use this order to avoid jumping between unrelated checks and to quickly isolate whether the problem is process, network, config, or storage related.

flowchart TD
    A[Locate mysql and mysqld binaries] --> B[Check mysqld service status]
    B --> C{Running}
    C -- no --> D[Read error log and my.cnf paths]
    D --> E[Fix config, permissions, or disk issues]
    E --> F[Start service again]
    C -- yes --> G[Check port 3306 listener and socket]
    G --> H{Conflict found}
    H -- yes --> I[Stop conflicting process or change port]
    H -- no --> J[Test login and mysqladmin status]
    J --> K[Review slow queries and host performance]

Confirm MySQL binaries and service state

Start by confirming the client binary location, then verify whether mysqld is running.

which mysql
locate mysql
ps -ef | grep [m]ysqld

Service control commands differ by init system. Many older guides use SysV-style commands; modern distributions usually use systemd.

Tasksystemd-based LinuxSysV init (legacy)
Check statussystemctl status mysqld
or systemctl status mysql
service mysqld status
Start / stop / restartsystemctl start|stop|restart mysqld/etc/init.d/mysqld start|stop|restart
or service mysqld start|stop|restart
If service is missingValidate installed package/service nameLegacy registration sometimes used chkconfig with scripts under /etc/init.d

Check port 3306 binding and process conflicts

If MySQL reports Address already in use, verify which process owns TCP 3306.

ss -ltnp | grep :3306
lsof -i TCP:3306
netstat -lp | grep 3306
netstat -tap | grep mysql
ps -aux | grep mysql
CommandBest useWhat to look for
ss -ltnpModern listener checkPID/program bound to 3306
lsof -i TCP:3306Process-to-port mappingWhether mysqld owns the socket
netstat -lp / -tapLegacy systemsListener and owning process
ps … grep mysqldProcess existence checkRunning daemon and possible duplicates

If 3306 is not listening under mysqld, either MySQL is down or configured for another port/socket in my.cnf.

Find my.cnf and verify critical settings

When startup or connectivity fails, confirm configuration file location and validate key directives.

whereis my.cnf
locate my.cnf
find / -name my.cnf
strace mysql ";" 2>&1 | grep cnfCode language: JavaScript (javascript)
PlatformCommon default option files (original guide)
Linux/etc/my.cnf
/etc/mysql/my.cnf
/usr/etc/my.cnf
~/.my.cnf
WindowsC:\Windows\my.ini
C:\Windows\my.cnf
C:\my.ini
C:\my.cnf
C:\Program Files\MySQL\MySQL Server 5.5\my.ini
C:\Program Files\MySQL\MySQL Server 5.5\my.cnf

Important parameters to verify in my.cnf:

  • datadir (data directory path)
  • log-error (error log file path)
  • pid-file (daemon PID file path)
  • tmpdir
  • default-character-set
  • default-storage-engine
  • innodb_data_home_dir (if used)

Diagnose startup failures from logs and filesystem state

If mysqld will not start, check logs first, then ownership/permissions of datadir and available disk space.

# Locate configured log path in my.cnf
grep -R "log-error\|datadir\|pid-file" /etc/my.cnf /etc/mysql/my.cnf 2>/dev/null

# Review error output
tail -n 200 /var/log/mysqld.log
# or (systemd hosts)
journalctl -u mysqld -n 200 --no-pager

# Check data directory permissions and free space
ls -ld /var/lib/mysql
df -hCode language: PHP (php)

For local hostname resolution issues, verify localhost mapping exists:

grep "127.0.0.1" /etc/hostsCode language: JavaScript (javascript)

Recover crashed tables

The original guide shows table-crash errors during startup and uses SQL repair plus mysqlcheck. Start with targeted repair, then broaden if needed.

mysql -u root -p
REPAIR TABLE database1.table1;
SHOW CREATE DATABASE database1;Code language: CSS (css)
# Optimize + auto-repair one database
mysqlcheck -u username -p -o --auto-repair -v --optimize database_name

# Check/repair all databases
mysqlcheck -u root -p --auto-repair --check --optimize --all-databasesCode language: PHP (php)

Note: behavior differs by storage engine. Validate engine-specific recovery steps before running repair operations broadly.

Quick performance triage on host and MySQL

Use short-interval OS metrics and then correlate with MySQL slow queries and error logs.

top
vmstat 5
iostat -x 5

# If slow query logging is enabled, inspect the log configured in my.cnf
# and review long-running statementsCode language: PHP (php)
ToolWhat it helps detectTypical signal
topCPU contention by processmysqld or non-MySQL process saturating CPU
vmstat 5CPU, memory, and I/O wait trendHigh wa values over multiple samples
iostat -x 5Disk saturation and latencyBusy device with sustained high utilization
Slow query logInefficient SQLRepeated high-latency queries

Use mysqladmin for quick health checks

mysqladmin is useful for lightweight checks without entering the interactive MySQL shell.

mysqladmin -h hostname -p ping
mysqladmin -h hostname -p status
mysqladmin -h hostname -p variables
mysqladmin -h hostname -p processlist
mysqladmin -h hostname -p flush-logs
mysqladmin -h hostname -p flush-status
mysqladmin -h hostname -p shutdown
mysqladmin commandPurpose
pingCheck whether server is reachable
statusShort runtime summary (uptime, threads, queries)
variablesShow server variables and values
processlistList active server threads
flush-logsRotate and reopen logs
shutdownStop server cleanly

Connectivity checks from clients

For network-level troubleshooting, test TCP reachability from the calling host.

telnet your_host_name 3306
# alternative if telnet is unavailable
nc -vz your_host_name 3306Code language: PHP (php)

References from the original post

Best practices and common pitfalls

  • Always read the MySQL error log first before restarting repeatedly.
  • Do not assume service name is always mysqld; some systems use mysql.
  • Verify datadir ownership and free disk space during startup failures.
  • Confirm who owns TCP 3306 before changing configuration.
  • Use staged repair: single table, then single database, then all databases only when necessary.
  • Capture baseline metrics (CPU, memory, disk, slow queries) before and after fixes.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

4 Open Source Alternatives to Slack for Team Chat: IRC, Let’s Chat, Mattermost, and Rocket.Chat

If you want Slack-like team communication with more control, these four open source options are a practical starting point. This guide compares their strengths, trade-offs, and how to run a short technical pilot.

Read More

jstack Utility Deep Dive: JVM Thread Dumps, Deadlocks, and Mixed Stacks

This guide explains how to use jstack to diagnose JVM hangs and deadlocks, including forced dumps, core-file analysis, and mixed Java/native stack traces. It also clarifies where jcmd fits in modern JDK 8+ troubleshooting guidance.

Read More

Open Source Scanning Software: Evaluate Legacy Tools and Build a Modern SCA Workflow

The original post listed several tool names but no implementation guidance. This revised guide explains what open source scanning means in DevSecOps, how to interpret those legacy names, and how to implement a practical CI scanning workflow.

Read More

Lyca Mobile USSD Shortcuts: Check Balance and Data Balance Quickly

Use these Lyca Mobile USSD shortcuts to check your prepaid balance and remaining data in seconds. This updated reference includes quick steps, a workflow diagram, and troubleshooting guidance.

Read More

Single Sign-On Implementations: Practical Comparison and Evaluation Guide

This guide expands a short 2015 link list of SSO tools into a practical DevOps reference. You will learn how SSO flows work, how to compare implementations, and how to validate integrations with real commands.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x