After installing the lamp environment, test the database connection.
When host uses 127.0.0.1, error: (hy000/2002): Permission denied.
Replace host with localhost, and error: sqlstate[hy000] [2002] No such file or directory.
The last discovery is because SELinux is not turned off, and it is usually enabled by default when the download is finished CentOS7.
[[Email protected] ~] # sestatus SELinux Status: enabled selinuxfs mount: /sys/fs/selinux selinux root directory: /etc/selinux Loaded policy name: targeted current mode : Enforcing file: enforcing Policy MLS status: enabled Policy Deny_unknown status: allowed Max kernel policy version: 28
If you want to close temporarily, you can do this:
setenforce 0
At this point the status is as follows:
[[Email protected] ~] # sestatus SELinux Status: enabled selinuxfs mount: /sys/fs/selinux selinux root directory: /etc/selinux Loaded policy name: targeted current mode : Permissive file: enforcing Policy MLS status: enabled Policy Deny_unknown status: allowed Max kernel policy version: 28
If you want to close permanently, you can modify the configuration file/etc/selinux/config and set Selinu to Disabled.
[[Email protected] ~]#Cat/etc/selinux/config #This file controls the state of the SELinux on the system. #selinux= can take one of these three values:#Enforcing-selinux security policy is enforced. #Permissive-selinux prints warnings instead of enforcing. #disabled-no SELinux policy is loaded. #selinux=enforcingselinux=Disabled#Selinuxtype= can take one of three the values:#targeted-targeted processes is protected,#Minimum-modification of targeted policy. Only selected processes is 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 following status:
[[Email protected] ~] # sestatus SELinux Status: disabled
The article my pro-test effective.
Posts reprinted: 48265445
Centos7 database connection using 127.0.0.1 Permission denied, using localhost to report no such file or directory