After digging and digging I even managed to bring by default the mysqld.pid file (which by default resides in /run/mysqld) into the new MariaDB datadir.
I also managed to fix (temporarily) this issue by following the steps below but unfortunately as the symlink /run/mysqld → /db does NOT survive to the reboot, this cannot be considered a solution AT ALL:
cd /run
mv mysqld/ mysqld.backup
ln -s /db mysqld
systemctl start mariadb
Eventually I realized that the proper solution consists of all the steps I published in the first post of this thread but without modifying the path for the socket within the /etc/mysql/my.cnf file:
So instead of this:
[client]
port=3306
socket=/db/mysqld.sock
[mysqld]
socket=/db/mysqld.sock
datadir=/db
I should have done this in file:
[client]
port=3306
socket=/var/run/mysqld/mysqld.sock
[mysqld]
socket=/var/run/mysqld/mysqld.sock
datadir=/db
Before I close, however, I would be glad if someone could tell me how to make the symlink below survive to a reboot in ubuntu with MariaDB:
ln -s /db /var/run/mysqld
Thanks!