Today, I realized that on Ubuntu 18.04, the usual MySQL (version 5.7.26) config file in /etc/mysql/my.cnf is a symbolic link and and world-readable/writable. What is interesting is that the file that it points to is another symbolic link pointing back to my.cnf. Why is that? And if we want to change the config, which file should we edit? Also, isn't it a really awful decision to make it world-readable/writable by default?
# ls -l /etc/mysql/
drwxr-xr-x 2 root root 4096 May 21 16:30 conf.d
-rwxr-xr-x 1 root root 120 Apr 25 18:10 debian-start
-rw------- 1 root root 317 May 21 16:30 debian.cnf
lrwxrwxrwx 1 root root 24 May 21 16:30 my.cnf -> /etc/alternatives/my.cnf
-rw-r--r-- 1 root root 839 Aug 3 2016 my.cnf.fallback
-rw-r--r-- 1 root root 682 Jan 12 2018 mysql.cnf
drwxr-xr-x 2 root root 4096 May 21 16:30 mysql.conf.d
# ls -l /etc/alternatives/my.cnf
lrwxrwxrwx 1 root root 20 May 21 16:30 /etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf
Note: This is a clean Ubuntu & MySql installation with mysql_secure_installation command. Nothing else has been changed.