Affected versions: Ubuntu 26.04 LTS

πŸ“– ~1 min read

Table of contents
  1. Symptom & Impact
  2. Environment & Reproduction
  3. Root Cause Analysis
  4. Quick Triage
  5. Step-by-Step Diagnosis
  6. Solution – Primary Fix
  7. Solution – Alternative Approaches
  8. Verification & Acceptance Criteria
  9. Rollback Plan
  10. Prevention & Hardening
  11. Related Errors & Cross-Refs
  12. References & Further Reading

Symptom & Impact

Applications fail with cannot connect to local MySQL socket errors.

Environment & Reproduction

Appears after config edits, datadir moves, or service restarts.

sudo systemctl status mysql
mysql -uroot -p
ls -l /var/run/mysqld

Root Cause Analysis

mysqld not running, socket path mismatch, or directory permission problems.

Quick Triage

Check mysql service status and configured socket paths.

sudo journalctl -u mysql -n 120
grep -R socket /etc/mysql -n
ss -ltnp | grep 3306

Step-by-Step Diagnosis

Compare client and server socket config and validate runtime directory ownership.

sudo mysqld --verbose --help | grep socket | head -n 5
stat /var/run/mysqld
cat /etc/mysql/mysql.conf.d/mysqld.cnf | grep socket
Illustrative mockup for ubuntu-26-04-lts β€” terminal_or_shell
MySQL socket and service diagnostics β€” Illustrative mockup β€” Progressive Robot

Solution – Primary Fix

Correct socket path/permissions and restart mysql service.

Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
sudo systemctl restart mysql
Illustrative mockup for ubuntu-26-04-lts β€” logs_or_journal
mysqld startup and error logs β€” Illustrative mockup β€” Progressive Robot

Solution – Alternative Approaches

Use TCP localhost connection while socket path issue is remediated.

mysql -h 127.0.0.1 -P 3306 -u root -p

Verification & Acceptance Criteria

Local and application connections succeed without socket errors.

mysqladmin ping
mysql -uroot -p -e 'select 1;'

Rollback Plan

Restore previous mysql config files if custom path change introduced regressions.

sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf.bak /etc/mysql/mysql.conf.d/mysqld.cnf
sudo systemctl restart mysql

Prevention & Hardening

Template socket settings consistently across clients and server roles.

grep -R socket /etc/mysql -n
systemctl is-enabled mysql

Related to AppArmor denials, datadir mount issues, and auth plugin mismatches.

Related tutorial: View the step-by-step tutorial for Ubuntu 26.04 LTS.

View all Ubuntu 26.04 LTS tutorials on the Tutorials Hub β†’

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

Ubuntu MySQL service administration and troubleshooting guides.

Need Expert Help?

If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today β€” we respond within one business day.