After installing the lamp environment, test the database connection.
When host uses 127.0.0.1, the error is: (hy000/2002): Permission denied.
After replacing the host with localhost, it also complains: sqlstate[hy000] [2002] No such file or directory.
The final discovery is that SELinux is not turned off, and SELinux is enabled by default after CentOS7 is installed.
[Root@rdo ~]# sestatus
SELinux Status: enabled
SELINUXFS mount: /sys/fs/selinux SELinux
Root Directory: /etc/selinux
Loaded policy name: targeted current
mode: enforcing
mode from Config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max Kernel policy version: 28
If you want to temporarily close, you can perform:
Setenforce 0
At this point the status is as follows:
[Root@rdo ~]# sestatus
SELinux Status: enabled
SELINUXFS mount: /sys/fs/selinux SELinux
Root Directory: /etc/selinux
Loaded policy name: targeted current
mode: permissive
mode from Config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max Kernel policy version: 28
If you want to shut down permanently, you can modify the profile/etc/selinux/config to Selinu to disabled.
[Root@rdo ~]# cat/etc/selinux/config # This file controls to the state of SELinux on the
system.
# selinux= can take one of these three values:
# Enforcing-selinux The security policy is enforced.
# Permissive-selinux Prints warnings instead of enforcing.
# Disabled-no SELinux policy is loaded.
#SELINUX =enforcing
selinux=disabled
# selinuxtype= can take one of three two values:
# targeted- Targeted processes are protected,
# Minimum-modification of targeted policy. Only selected processes are protected.
# Mls-multi level security protection.
selinuxtype=targeted
Modifying the configuration file can also be done by executing the following command:
After the modification is complete, save the reboot, and reboot after the status as follows:
[Root@rdo ~]# sestatus
SELinux Status: disabled