Score:1

MySQL 8.0 service won't start "directory exists"

tr flag

Environment:

  • Ubuntu 20.04 cloud image, initiated with cloud-config with total 9 hdds.
  • mysql-server 8.0.27 installed with apt.
  • Two logical volumes with four hdds each (sdb-e, sdf-i) mounted rw on /mysql/data and /mysql/log.
  • User mysql owns /mysql and all subdirs and can write to them.
  • Configuration file in /etc/mysql/conf.d/mysql.cnf defines basedir as /var/lib/mysql (where all the default stuff is from the installation) and datadir as /mysql/data.

Problem:

  • Enable/start mysql.service fails the pre-check with a message that the directory /mysql/data already exists, and will not start.

How does one get around this catch22 situation?

in flag
Sounds like an `AppArmor` issue. Check your configuration to ensure the MySQL section has proper `[r,w]` values for the directories you’ve created
Score:1
tr flag

This solved the problem:

# Allow directory changes in AppArmor
sudo sed -i '/\# Allow data files dir access/a /mysql/** rwk,' /etc/apparmor.d/usr.sbin.mysqld
sudo systemctl stop apparmor.service
sleep 10
sudo systemctl start apparmor.service

removed the lost+found folders from the /mysql/ subfolders and initialized the db using

sudo -u mysql mysqld --initialize
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.