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 

centos7安装mysql5.7

在线安装MySQL

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

yum -y install mysql-community-server

centos7安装mysql5.7

启动mysql

systemctl start mysqld

centos7安装mysql5.7

设置开机自启

systemctl enable mysqld
systemctl daemon-reload

centos7安装mysql5.7

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

vim /var/log/mysqld.log

centos7安装mysql5.7

KVqXHkNxv0<- 就是生成的密码

mysql -uroot -p

输入复制的密码

centos7安装mysql5.7

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

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

远程登陆开启

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

centos7安装mysql5.7

退出

exit

开放3306端

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

centos7安装mysql5.7

配置mysql编码

vim /etc//my.cnf

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

character_set_server=utf8

init_connect=‘SET NAMES utf8‘

centos7安装mysql5.7

wq!保存退出

重启mysql

systemctl restart mysqld

测试远程连接

centos7安装mysql5.7

centos7安装mysql5.7

centos7安装mysql5.7

上一篇:docker-compose部署nodejs+eggjs+mysql+redis+nginx项目


下一篇:ThinkPHP6.0 缓存类型包括file、memcache、wincache、sqlite、redis