How to change permissions to mysql pid file
There's no need. You can check the existence of the file without changing the permissions:

if [ -f /var/run/mysqld/mysqld.pid ]; then     echo "mysqld running"; fi


If that's not good enough you can check the pid (i.e. the contents of the file) directly:

ps -U mysql | grep mysqld | cut -f1 -d' '