start the service
systemctl start mariadb.service
systemctl enable mariadb.service
systemctl stop mariadb.service
1. First enable mysql permissions
Set ROOT password
mysqladmin -u root password '888888'
mysql -u root -p
use mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION;
flush privileges;
The "%" in the first sentence means that any host can log in to the server remotely. If you want to restrict access to only a certain machine, you can replace it with the corresponding IP, such as:
GRANT ALL PRIVILEGES ON *.* TO root@"172.168.193.25" IDENTIFIED BY "root";
select * from user where user='root';
Check if there is % this record
2. Open port 3306 and other commonly used ports
Check if there is this file /etc/sysconfig/iptables, if not
iptables -P OUTPUT ACCEPT
service iptables save to save, the default is saved to the iptables file in the /etc/sysconfig directory
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #Allow 3306 database port through the firewall
service iptables save
cat /etc/sysconfig/iptables has 3306 pieces of information
service iptables restart is ok
Other common ports:
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #Allow port 80web to pass through the firewall
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
iptables -A INPUT -p tcp --dport 110 -j ACCEPT #email
iptables -A INPUT -p tcp --dport 25-j ACCEPT #email
iptables -A INPUT -p tcp --dport 20-j ACCEPT #ftp
iptables -A INPUT -p tcp --dport 21-j ACCEPT #ftp
iptables -A INPUT -p icmp -j ACCEPT #ping
iptables -A INPUT -p udp --dport 53 -j ACCEPT #DNS
3. Check whether the firewall is turned on:
service iptables status
active means open, inactive means close
firewall-cmd --state
norunning
4. Commands about the firewall
Permanent effect after restart:
Enable: chkconfig iptables on
Off: chkconfig iptables off
Effective immediately, invalid after restart:
Start: service iptables start
closure:
service iptables stop
Restart: service iptables restart
Save configuration: service iptables save
or /etc/rc.d/init.d/iptables save
#Set the firewall to start at boot
systemctl enable iptables.service
Prevent firewall from starting at system startup
/sbin/chkconfig --level 2345 iptables off
5. Delete iptables rules
View current rules
iptables -L -n
iptables -L -n --line-number
iptables -D INPUT 3