Linux Redhat 4.4.7 安装 8.0.13 MySQL Community Server

时间:2022-05-02 09:26:40

1.刚开始安装mysql参考这个:

    https://blog.csdn.net/a116475939/article/details/74625377

2.修改密码

mysql> use mysql;
     #先把密码置为空字符串;(不让后面修改密码会报错)
mysql> update user set authentication_string="" where user="root";
     #这个刷新非常有必要;不让后面执行alter就会出错
mysql> flush privileges;
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '密码';

3.创建用户以及赋权

mysql> create user 'shenbo'@'%' identified by '$mima...';
Query OK, 0 rows affected (0.21 sec)
mysql> grant all privileges on *.* to 'shenbo'@'%' ;
Query OK, 0 rows affected (0.06 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 4.设置防火墙 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 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

然后执行 service iptables restart