当前位置:网站首页>CentOS7安装MySQL5.7
CentOS7安装MySQL5.7
2022-07-28 05:16:00 【jekyhu】
目录
(1)下载MySQL5.7安装包
(2)MySQL5.7安装包上传到linux服务器
(3)检查系统是否安装过MySQL用户组,没有就创建
(4)卸载CentOS7系统自带mariadb
(5)安装MySQL5.7步骤
一、下载MySQL5.7安装包
下载地址:mysql-5.7.36-linux-x86_64-MySQL文档类资源-CSDN下载
二、MySQL5.7安装包上传到linux服务器
linux服务器根目录中usr目录下新建文件夹:software
software用来存放各种软件。
将下载好的mysql5.7安装包上传至software文件夹下:

三、检查系统是否安装过MySQL用户组,没有就创建
检查mysql 用户组是否存在
cat /etc/group | grep mysql
cat /etc/passwd |grep mysql
这里不显示就代表没有。
创建mysql 用户组和用户
代码和结果如下:
groupadd mysql
useradd -r -g mysql mysql![]()
重新查看用户组:

四、卸载CentOS7系统自带的数据库
查看系统自带的Mariadb
rpm -qa|grep mariadb![]()
卸载系统自带的Mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
此时再执行查询就没有这个数据库了。
删除etc目录下的my.cnf ,后面再重新建。
这里的etc目录在根目录下面。
rm /etc/my.cnf五、安装mysql5.7
- 解压安装mysql安装包到目录下
tar -zxvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz

修改mysql-5.7.36-linux-glibc2.12-x86_64名称为mysql5.7
mv mysql-5.7.36-linux-glibc2.12-x86_64 mysql5.7
更改mysql5.7 目录下所有文件夹所属的用户组、用户以及权限
chown -R mysql:mysql /usr/software/mysql5.7
chmod -R 755 /usr/software/mysql5.7
进入/usr/software/mysql5.7/bin/目录,编译安装并初始化mysql,务必记住数据库管理员临时密码。在最后一行。
./mysqld --initialize --user=mysql --datadir=/usr/software/mysql5.7/data --basedir=/usr/software/mysql5.7
如图,此密码就是qy2Hg+mL%=1Q
编写etc目录下的my.cnf 配置文件,并添加配置
上面将my.cnf删除了,这里也可以新建一个然后进入。
vi /etc/my.cnf
将下面的复制到文件中,然后保存
[mysqld]
datadir=/usr/software/mysql5.7/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
授予my.cnf 配置文件775权限,如下:
chmod -R 775 /etc/my.cnf修改/usr/software/mysql5.7/support-files/目录下的mysql.server文件,如下图中5个位置的/usr/local/mysql全部修改成/usr/software/mysql5.7。
因为没有安装在默认的/usr/local/mysq目录下,所以需要修改成自己安装的路径。

启动mysql 服务器
1、查询服务
ps -ef|grep mysql
ps -ef|grep mysqld
2、启动服务
/usr/software/mysql5.7/support-files/mysql.server start
添加软连接,并重启mysql 服务
ln -s /usr/software/mysql5.7/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/software/mysql5.7/bin/mysql /usr/bin/mysqlservice mysql restart
登录mysql ,密码就是初始化时生成的临时密码
mysql -u root -p
修改初始密码为自己的密码
set password for [email protected] = password('xxxxxxx');
开放远程连接
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;
设置开机自启
cp /usr/software/mysql5.7/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list
开放3306端口,测试本地客户端是否连接成功
打开3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
配置立即生效
firewall-cmd --reload
这里爆红是因为我之间就开放过3306端口。
windows使用navicat连接测试一下

连接上了,说明远程连接完成。

你已经成功在centos中安装好了mysql!
边栏推荐
- Flink mind map
- Clickhouse填坑记2:Join条件不支持大于、小于等非等式判断
- C language classic 100 question exercise (1~21)
- 【ARXIV2204】Vision Transformers for Single Image Dehazing
- Activation functions sigmoid, tanh, relu in convolutional neural networks
- SimpleDateFormat线程不安全和DateTimeFormatter线程安全
- MySQL 默认隔离级别是RR,为什么阿里等大厂会改成RC?
- [paper notes] - low illumination image enhancement - zeroshot - rrdnet Network - 2020-icme
- MySQL basic query
- From the basic concept of micro services to core components - explain and analyze through an example
猜你喜欢

CPU and memory usage are too high. How to modify RTSP round robin detection parameters to reduce server consumption?

使用navicat或plsql导出csv格式,超过15位数字后面变成000(E+19)的问题

Professor dongjunyu made a report on the academic activities of "Tongxin sticks to the study of war and epidemic"

Offline loading of wkwebview and problems encountered

ES6 new variable modifiers let and const, new basic data type symbol

PC side bug record

Struct模块到底有多实用?一个知识点立马学习
![[slam] lvi-sam analysis - Overview](/img/66/f15f6f574807b9a783e9321c71d422.png)
[slam] lvi-sam analysis - Overview

【内功心法】——函数栈帧的创建和销毁(C实现)

【ARXIV2203】Efficient Long-Range Attention Network for Image Super-resolution
随机推荐
类和对象【中】
为什么md5不可逆,却还可能被md5免费解密网站解密
C language characters and strings
2022 summer practice (first week)
MySQL practice 45 lectures
I've been in an outsourcing company for two years, and I feel like I'm going to die
Oracle创建表、删除表、修改表(添加字段、修改字段、删除字段)语句总结
Printf function of input and output function in C language
C language: addition and deletion of linked list in structure
HDU 1914 the stable marriage problem
Share several methods of managing flag bits in C program
Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions
HDU 1522 marriage is stable
First acquaintance with C language (2)
HDU 3078 network (lca+ sort)
How about ink cloud?
Simulink automatically generates STM32 code details
First acquaintance with C language (1)
在ruoyi生成的对应数据库的代码 之后我该怎么做才能做出下边图片的样子
Struct模块到底有多实用?一个知识点立马学习