Affected versions: Ubuntu 22.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

Database service remains down after datadir relocation, breaking application startup and transactions.

Environment & Reproduction

Seen when MySQL datadir is moved without updating AppArmor rules.

Root Cause Analysis

AppArmor profile for mysqld does not permit access to new storage path, so startup aborts.

Quick Triage

Check kernel audit denials and mysql error logs for AppArmor path violations.

Step-by-Step Diagnosis

Confirm datadir path and required file access patterns in mysqld profile.

Illustrative mockup for ubuntu-22-04-lts β€” services_panel
mysql service denied by AppArmor profile β€” Illustrative mockup β€” Progressive Robot

Solution – Primary Fix

Add correct datadir rules to AppArmor local override and reload profile before restarting MySQL.

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

Illustrative mockup for ubuntu-22-04-lts β€” log_or_config
AppArmor profile updated for custom MySQL datadir β€” Illustrative mockup β€” Progressive Robot

Solution – Alternative Approaches

Return datadir to default location if profile changes are restricted by policy.

Verification & Acceptance Criteria

MySQL starts normally and no new AppArmor denials occur for mysqld process.

Rollback Plan

Remove custom profile lines and revert datadir setting if application behavior regresses.

Prevention & Hardening

Include AppArmor profile updates in any database storage migration procedure.

Often appears with file ownership issues and SELinux assumptions imported from non-Ubuntu guides.

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

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

Browse all common problems & solutions on the Tutorials Hub.

References & Further Reading

Ubuntu AppArmor and MySQL deployment documentation.

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.