当前位置:网站首页>centos7安装mysql5.7
centos7安装mysql5.7
2022-07-31 04:47: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 database addition, deletion, modification and query (detailed explanation of basic operation commands)
- Go language study notes - dealing with timeout problems - Context usage | Go language from scratch
- DVWA靶场环境搭建
- MySQL修改root账号密码
- 高斯分布及其极大似然估计
- [R language] [3] apply, tapply, lapply, sapply, mapply and par function related parameters
- HCIP第十天_BGP路由汇总实验
- BUG destroyer!!Practical debugging skills are super comprehensive
- unity2d game
- MySQL database must add, delete, search and modify operations (CRUD)
猜你喜欢

Lua,ILRuntime, HybridCLR(wolong)/huatuo hot update comparative analysis

C语言表白代码?

Industry landing presents new progress | 2022 OpenAtom Global Open Source Summit OpenAtom OpenHarmony sub-forum was successfully held

三子棋的代码实现

ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your

The idea project obviously has dependencies, but the file is not displayed, Cannot resolve symbol 'XXX'

Open Source Smart Future | 2022 OpenAtom Global Open Source Summit OpenAtom openEuler sub-forum was successfully held

打造基于ILRuntime热更新的组件化开发

VScode+ESP32 quickly install ESP-IDF plugin

MySQL database must add, delete, search and modify operations (CRUD)
随机推荐
STM32HAL库修改Hal_Delay为us级延时
sql语句之多表查询
Recursive implementation of the Tower of Hanoi problem
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)
.NET-6.WinForm2.NanUI学习和总结
Reinforcement learning: from entry to pit to shit
PCL calculates the point cloud coordinate maximum and its index
Vue项目通过node连接MySQL数据库并实现增删改查操作
binom二项分布,
Lua,ILRuntime, HybridCLR(wolong)/huatuo hot update comparative analysis
Puzzle Game Level Design: Reverse Method--Explaining Puzzle Game Level Design
Interview | Cheng Li, CTO of Alibaba: Cloud + open source together form a credible foundation for the digital world
.NET-9.乱七八糟的理论笔记(概念,思想)
C Implementation of Simple Network File Copy
MySQL to revise the root password
unity2d game
DVWA之SQL注入
three.js make 3D photo album
MATLAB/Simulink&&STM32CubeMX工具链完成基于模型的设计开发(MBD)(三)
qlib自动化quant