当前位置:网站首页>Centos7 install mysql5.7
Centos7 install mysql5.7
2022-07-31 04:55:00 【jiey0407】
一、下载mysql5.7
1、下载地址:点击跳转

2、然后上传到服务器上面
解压命令
tar -xvf mysql-5.7.36-1.el7.x86_64.rpm-bundle.tar
3、解压后得到以下的rpm包
4、依次安装所需要的rpm包
rpm -ivh mysql-community-common-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.36-1.el7.x86_64.rpm
如果出现以下报错,则在上面命令最后加上 --force --nodeps
例如:
rpm -ivh mysql-community-libs-5.7.36-1.el7.x86_64.rpm --force --nodeps


5、查看安装情况
rpm -qa | grep mysql

就此安装成功了!!!
二、启动mysql服务
启动指令
systemctl start mysqld.service
如果启动报错,可以执行journalctl -xe指令查看错误信息
我这里提示找不到这个libaio
查看是否安装了libaio,如下图:
rpm -qa | grep libaio

空空如也,说明没有安装
使用yum命令安装一下
yum install -y libaio
然后再执行启动命令即可
systemctl start mysqld.service
.
1、查看初始密码(要记住这个密码之后会用到)
cat /var/log/mysqld.log | grep password

2、用初始化的密码登录mysql
mysql -uroot -p

3、重置密码
SHOW variables LIKE 'validate_password%';
有可能会报这个错误
exit退出mysql控制台
编辑mysql的配置文件
vi /etc/my.cnf
新增这行两行配置
#添加密码验证插件
plugin-load-add=validate_password.so
#服务器在启动时加载插件,并防止在服务器运行时删除插件
validate-password=FORCE_PLUS_PERMANENT

然后保存退出,重启mysql
mysql重启指令:
systemctl restart mysqld
4、重启完之后进入mysql服务器,设置新密码
进入mysql指令
mysql -uroot -p
5、修改验证策略为low
set global validate_password_policy=0;
6、修改最短密码长度为1
set global validate_password_length=1;
7、设置新密码的指令:
123456可以改成你想要的密码
alter user 'root'@'localhost' identified by '123456';

8、设置完成后重新进入mysql服务器,输入新的密码进行登录
就此密码设置完毕!!!
三、开放mysql数据库的端口
.
设置远程连接(前提:关闭防火墙或开放3306端口)
.
1、查看防火墙是否关闭
systemctl status firewalld.service

先暂时关闭防火墙,然后再永久关闭防火墙
systemctl stop firewalld.service #暂时关闭防火墙
systemctl disable firewalld.service #永久关闭防火墙

2、设置mysql远程连接权限
登录进入mysql控制台
show databases;
use mysql;
select user,host from user;
update user set host = '%' where user = 'root'; # %为任意访问地址
flush privileges; # 刷新权限 权限更新后刷新才会起作用

四、设置mysql中文编码
编辑配置文件
vim /etc/my.cnf
新增以下配置:
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

然后保存退出,重启mysql服务
重启指令:
systemctl restart mysqld
就此完成mysql的编码设置!!!
五、设置mysql开机启动
修改rc.local
vim /etc/rc.local
添加自启动,然后保存退出
service mysqld start

六、连接数据库

连接成功!!!
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在.深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小.自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前.因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担.添加下方名片,即可获取全套学习资料哦
边栏推荐
- mysql数据库安装(详细)
- input输入框展示两位小数之precision
- From scratch, a mirror to the end, a pure system builds a grasscutter (Grasscutter)
- Sun Wenlong, Secretary General of the Open Atom Open Source Foundation |
- Lua,ILRuntime, HybridCLR(wolong)/huatuo hot update comparative analysis
- Mysql应用安装后找不到my.ini文件
- Minesweeper game (written in c language)
- MySQL事务隔离级别详解
- Summary of MySQL common interview questions (recommended collection!!!)
- MySQL优化之慢日志查询
猜你喜欢

Go语学习笔记 - 处理超时问题 - Context使用 | 从零开始Go语言

MySQL数据库增删改查(基础操作命令详解)

Solved (the latest version of selenium framework element positioning error) NameError: name 'By' is not defined

Puzzle Game Level Design: Reverse Method--Explaining Puzzle Game Level Design

ERP生产作业控制 金蝶

DVWA installation tutorial (understand what you don't understand · in detail)

MySQL事务隔离级别详解

Two address pools r2 are responsible for managing the address pool r1 is responsible for managing dhcp relays

DVWA shooting range environment construction

城市内涝及桥洞隧道积水在线监测系统
随机推荐
STM32HAL library modifies Hal_Delay to us-level delay
Understanding of the presence of a large number of close_wait states
.NET-9.乱七八糟的理论笔记(概念,思想)
The Vue project connects to the MySQL database through node and implements addition, deletion, modification and query operations
open failed: EACCES (Permission denied)
MySQL数据库安装配置保姆级教程(以8.0.29为例)有手就行
【R语言】【3】apply,tapply,lapply,sapply,mapply与par函数相关参数
MySQL database backup
Go language study notes - dealing with timeout problems - Context usage | Go language from scratch
从零开始,一镜到底,纯净系统搭建除草机(Grasscutter)
DVWA之SQL注入
Sql解析转换之JSqlParse完整介绍
[C language] Detailed explanation of operators
STM32HAL库修改Hal_Delay为us级延时
Industry-university-research application to build an open source talent ecosystem | 2022 Open Atom Global Open Source Summit Education Sub-Forum was successfully held
DVWA靶场环境搭建
Musk talks to the "virtual version" of Musk, how far is the brain-computer interaction technology from us
MySQL模糊查询可以使用INSTR替代LIKE
Three oj questions on leetcode
Vue项目通过node连接MySQL数据库并实现增删改查操作