centos7安装mysql5.7

Centos7安装mysql5.7

如果没有yum则输入命令安装

yum -y install wget

下载mysql安装文件

wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

安装mysql安装源

yum -y localinstall mysql57-community-release-el7-11.noarch.rpm 

image-20210624153811057

在线安装MySQL

安装的依赖比较多需要等待

yum -y install mysql-community-server

image-20210624153748334

启动mysql

systemctl start mysqld

image-20210624162323506

设置开机自启

systemctl enable mysqld
systemctl daemon-reload

image-20210624162415041

mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码

vim /var/log/mysqld.log

image-20210624162604644

KVqXHkNxv0<- 就是生成的密码

mysql -uroot -p

输入复制的密码

image-20210624162804084

修改密码,必须大小写和特殊字符

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@2021';

远程登陆开启

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Root@2021' WITH GRANT OPTION;

image-20210624163156537

退出

exit

开放3306端

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

image-20210624163343409

配置mysql编码

vim /etc//my.cnf

修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置

character_set_server=utf8

init_connect='SET NAMES utf8'

image-20210624163623308

wq!保存退出

重启mysql

systemctl restart mysqld

测试远程连接

image-20210624163819021

image-20210624163831376

posted @ 2021-06-24 17:30  Harry_666  阅读(109)  评论(0编辑  收藏  举报