The following ERROR may be reported during logon: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock '(2), because of/var/lib/mysql access permission issues. The following command changes the owner of/var/lib/mysql to the current user:
??$sudovim/etc/sysconfig/iptablesAdd the following content:
?-AINPUT-ptcp-mstate--stateNEW-mtcp--dport3306-jACCEPTSave and restart the Firewall:
?$sudoserviceiptablesrestartIn this way, other clients can connect to the mysql service.
What should I do if I forget the mysql logon password in the CentOS system? Use the security mode.
First, stop mysql in CentOS:
# Service mysqld stop
#/Usr/bin/mysqld_safe -- skip-grant-tables &
Enter the following information in the CentOS system:
Msql> mysql-u root-p
Enter the following password and press Enter.
The following describes how to reset the password in the CentOS system:
Mysql> update mysql. user set password = password ("new password") where user = "root ";
Refresh permission
Mysql> flush privileges;
Exit
Mysql> exit;
Start mysql and continue the previous logon action.
#/Rc. d/init. d/mysqld start
# Mysql-u root-p
In this way, we should be able to lose the mysql login password in the CentOS system. I hope you can learn the CentOS system in the same way.
1. configure the firewall and enable port 80 and port 3306
CentOS 7.0 uses firewall as the firewall by default. Here, it is changed to iptables firewall.
1. Disable firewall:
# Stop the firewall Service
Systemctl stop firewalld. service
# Disable firewall startup
Systemctl disable firewalld. service
2. Install iptables Firewall
# Installation
Yum install iptables-services
# Edit the firewall configuration file
Vi/etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [0: 0]
-A input-m state -- state ESTABLISHED, RELATED-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-I lo-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT
-A input-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited
COMMIT
: Wq! # Save and exit
# Restart the firewall to make the configuration take effect.
Systemctl restart iptables. service
# Set firewall startup
Systemctl enable iptables. service
Ii. Disable SELINUX
# Modifying the configuration file
Vi/etc/selinux/config
# SELINUX = enforcing # comment out
# SELINUXTYPE = targeted # comment out
SELINUX = disabled # Add
: Wq! # Save and exit
# Make the configuration take effect immediately
Setenforce 0