Today you need to install MySQL on a Linux server, and when you install MySQL, there is an error message:
[Root@localhost softwaretools]# RPM-IVH mysql-server-5.5.23-1.rhel5.x86_64.rpm
Preparing ... ########################################### [100%]
1:mysql-server ########################################### [100%]
Chown:invalid "Mysql:mysql": Invalid user
Chown:invalid "Mysql:mysql": Invalid user
Because MySQL in the installation of the need to create a MySQL group and MySQL users, see such a mistake, so think of, manually create groups and users, and then reload MySQL.
Result execution Command:
[Root@localhost softwaretools]# Groupadd MySQL
Groupadd: Unable to open the group file (groupadd:unable to open groups file)
At this point, it is strange, the current is clearly the root user, why not create groups and user permissions.
Next, is a pile of Baidu, Google, various blog forums.
To draw a little conclusion:
1, add users need to use the passwd and shadow these two files
2, add a group need to use the shadow and Gshadow these two files
At this point, the first sense, may be the problem of file permissions, using the Ls-l command to discover permissions are normal.
Strange very much, and then need to find the Niang and Google, finally found the problem, found 2 commands (Lsattr and chattr), because the hidden permissions in mischief:
A simple explanation of these 2 commands is:
[HTML] view plain copy can also append hidden permission settings for certain files that have special requirements, such as server logs. These hidden permissions include: Append only (a), compressed (c), no dump (d), immutable (i), Data journalling (j), secure deletion (s), no tail-m Erging (t), undeletable (U), no atime updates (A), Synchronous directory Updates (D), synchronous Updates (S), and top of Directory hierarchy (T). The lsattr command is to view hidden permission settings, chattr is the command to change hidden permissions.
First, use the lsattr to view these files:
[Java] view plain copy [root@localhost ~]# lsattr/etc/passwd-------------/etc/passwd [root@localhost ~]# Lsattr/etc/group----i--------/etc/group [root@localhost ~]# lsattr/etc/shadow-------------/etc/shadow [root@ localhost ~]# lsattr/etc/gshadow----i--------/etc/gshadow
I can see the file is set I this hidden permission, I: The settings file can not be deleted, renamed, set link relationship, can not write or add content. The I parameter is a great help for the security settings of the file system.
So as long as I get rid of the I right should be good.
Use the command chattr command to modify the file hide permissions, and execute the following command:
Chattr-i/etc/gshadow
Chattr-i/etc/group
Then manually add a user to test, the results can be performed normally.
Finally MySQL completely uninstall, reload, everything goes well.
Reference: http://blog.csdn.net/catoop/article/details/8364725