Linux 之 CentOS 7安装MySQL5.7

 

 ###首先要配置网卡文件有外网权限

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=b6b28604-2b25-480a-bc7c-287ed95304e4
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.0.101
NETMAKE=255.255.255.0
GATEWAY=192.168.0.1
DNS1=114.114.114.114
DNS2=8.8.8.8

1.下载MySQL yum 包

wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm


2.安装MySQL源

rpm -Uvh mysql57-community-release-el7-10.noarch.rpm

3.安装MySQL服务端

yum install -y mysql-community-server


systemctl start mysqld.service
systemctl status mysqld.service
 

4.获取临时密码

grep 'temporary password' /var/log/mysqld.log
 

5.登录mysql,修改密码

mysql -uroot -p


6.修改密码

更改密码规则

mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;

设置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';

7.开启远程连接

mysql> use mysql;
#%代表所有连接
mysql> update user set Host = '%' where Host = 'localhost' and User='root';
#刷新权限表
mysql> flush privileges;

 

一般默认自启

systemctl enable mysqld
systemctl daemon-reload

8.设置字符集

打开配置文件  修改成如下

vim /etc/my.cnf
 

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysql]
default-character-set=utf8

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
default-storage-engine=INNODB
character_set_server=utf8

symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid



重启mysql,使配置生效

service mysqld restart
 

9.放行3306端口

#放行3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
#重启防火墙
firewall-cmd --reload





ok


官网下载
https://dev.mysql.com/downloads/mysql/















posted @ 2021-09-13 11:14  昌北F4  阅读(105)  评论(0编辑  收藏  举报