create/write permission denied – mysql/mariadb/libman etc. – howto fix broken linux filesystem permissions with valid backup

after a reboot i could not start mysql anymore.

[ERROR] mysqld: Can't create/write to file '/usr/local/var/mysql/aria_log_control' 

after a while i noticed that man was not working anymore:

man-db: error while loading shared libraries: libmandb-2.8.1.so

slowly i started to understand that something serious did happen to the system. after executing

chmod o+x .

from / directory, also inside /lib/ and /lib/mysql/ and yes, man and mysql did work again!

afterwards i executed something, that i SHOULDNT execute:

chmod -R 755 /sbin /usr/ /lib /lib64 /var

https://superuser.com/questions/1252600/fix-permissions-of-server-after-accidental-chmod-debian/1769120#1769120

as someone recommended it as you can see in the link to fix permissionproblems, and my courier-auth-daemon did not start anymore, while mysql was running again.

after a reboot ssh did not let me in anymore, cause the private key had 755 aswell.

i realized that the ownership for / was not root anymore, but another user, cause of a malfunction of a php-script. i ended up syncing the permissions from a backup back to the system using the find command as described here:

https://serverfault.com/questions/971173/how-to-copy-ownership-and-permissions-using-rsync-but-not-the-files

be carfeul, it took me a lot of time, to get another backup, cause i missunderstood the commands of this link. it means

find . -exec chmod -v --reference='{}' /path/to/target/'{}' \;

copies the permissions from . (the folder you are in) to the /path/to/target/. – and not vice versa.

to copy the permissions from a target to the folder you’re currently inside, you need to use

find . -exec chmod -v –reference=/path/to/target/'{}‘ ‚{}‘ \;

…same as for chown….

so, in general: if you run into mysql-permission-problems check the rights of the entire hirachy and the owner of / ! this may help!

1 1 vote
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x