I've just installed a fresh version of MySQL on my CentOS machine. The problem I'm facing is that when I run this command:
# service mysqld start
I get in the console this error message:
[ERROR] Can't change data directory owner to mysql
I'm not exactly sure what it means and how to fix it. Any comments and solutions are welcome. Thanks!
EDIT
It seems like I've fixed it with:
chown -R mysql /var/lib/mysql
But the very same command # service mysqld start
now leads to another error message:
[ERROR] –initialize specified but the data directory has files in it. Aborting
Indeed, it has files, because during installation CentOS itself created this folder /var/lib/mysql
and put some files in it. I did not do anything manually. So, what the heck is going on with CentOS and how to fix it?? Thanks!!
EDIT
It seems like either MySQL or CentOS has gone crazy. The catch is, if I delete all files from data directory, on start-up (when I run #service mysqld start
) it creates a bunch of files in it, like ca-key.pem
and other .pem
files. So, it creates files and then throws an error, that the data directory is not empty. What a stupid behaviour! But how can I solve all this???
Best Answer
I had a similar issue with Kubernetes and MySQL 5.7 as well.
Adding the suggestion from yosifki to my container's definition got things working.
Here's an extract of my working YAML definition:
Here's an example snippet in docker-compose to clarify: