π ~1 min read
Table of contents
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.

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.

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.
Related Errors & Cross-Refs
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.