Bug #71912 MEM backup directory does not maintain permissions correctly
Submitted: 3 Mar 2014 12:54 Modified: 9 Jan 2015 10:12
Reporter: Simon Mudd (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Monitor: Installing Severity:S3 (Non-critical)
Version:3.0.7 OS:Linux (CentOS 5.x/6.x)
Assigned to: CPU Architecture:Any
Tags: Backup, mem, permissions, upgrade

[3 Mar 2014 12:54] Simon Mudd
Description:
I did an upgrade to 3.0.7 recently and there was an issue, which made me want to revert back to the 3.0.6 version that I had been using.

The MEM 3.0.7 linux installer does make a backup of the files to /opt/mysql/enterprise/monitor/backup
but when I tried to revert these files back under /opt/mysql/enterprise/monitor/ the embedded MySQL wold not start. It seems the permissions of the mysql/runtime directory is not as it should be.

How to repeat:
On trying to startup MEM I see the mysql startup fails. Logging says:

2014-03-03 13:38:45 27515 [ERROR] /opt/mysql/enterprise/monitor/mysql/bin/mysqld: Can't create/write to file '/opt/mysql/enterprise/monitor/mysql/runtime/mysqld.pid' (Errcode: 13 - Permission denied)
2014-03-03 13:38:45 27515 [ERROR] Can't start server: can't create PID file: Permission denied

The permissions of the runtime directory are:

[root@myserver monitor]# cd backup/mysql/
[root@myserver mysql]# ls -ld runtime/
drwxr-x--- 2 root root 40 Feb  4 10:14 runtime/
[root@myserver mysql]# ls -la runtime/
total 5728
drwxr-x---  2 root root      40 Feb  4 10:14 .
drwxr-xr-x 13 root root    4096 Feb 28 20:56 ..
-rw-r-----  1 root root 5854693 Feb 28 20:54 mysqld.log
-rw-rw----  1 root root       6 Feb  4 10:14 mysqld.pid
[root@myserver mysql]# 

and the MySQL user runs as user mysql.

Suggested fix:
So it looks to me as if the directory and file permissions are not maintained while moving files into backup/.  Please correct this as it saves time trying to restore things if a "recovery" is needed.

I didn't have a copy of the permissions used previously so changed them as shown, which works but may not be completely correct:

[root@myserver mysql]# pwd
/opt/mysql/enterprise/monitor/mysql
[root@myserver mysql]# ls -ld runtime/
drwxrwx--- 2 root mysql 40 Mar  3 13:45 runtime/
[root@myserver mysql]# ls -la runtime/
total 9800
drwxrwx---  2 root  mysql      40 Mar  3 13:45 .
drwxr-xr-x 13 root  mysql    4096 Mar  3 13:31 ..
-rw-r-----  1 mysql root  5869975 Mar  3 13:46 mysqld.log
-rw-rw----  1 mysql mysql       5 Mar  3 13:45 mysqld.pid
[root@myserver mysql]# 

The other option may be to have mysqlmonitorctl.sh have an option to fix / reset permissions to the expected ones (on startup?), though that may be more tricky.
[4 Mar 2014 5:25] MySQL Verification Team
Hello Simon,

Thank you for the bug report.

Thanks,
Umesh