linux(centos7)离线安装mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar

1. 卸载mariadb相关rpm

powershell 复制代码
# 查找
rpm -qa|grep mariadb
rpm -qa|grep mysql

# 卸载
rpm -e --nodeps mariadb...
rpm -e --nodeps mysql...

2. 删除mysql相关文件

powershell 复制代码
# 查找
find / -name mysql

# 删除
rm -rf /var/lib/mysql...

3. 查看是否有相关依赖,没有需安装

powershell 复制代码
rpm -qa|grep libaio

rpm -qa|grep net-tools

4. 解压mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar

powershell 复制代码
tar -xvf mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar

5. 安装mysql

powershell 复制代码
# 在解压的rpm路径下,安装所有rpm
rpm -ivh mysql* --force --nodeps

6. 修改配置文件(修改后报错,datadir目录用户权限不是mysql,需重新赋权限,待验证)

powershell 复制代码
# 打开 mysql 默认配置文件
vim /etc/my.cnf

# 数据存储路径
datadir=/usr/local/mysql/data

7. 启动MySQL服务

powershell 复制代码
# 启动
service mysqld start

# 查看状态
service mysqld status


8. 修改MySQL密码

powershell 复制代码
# 查看密码
cat /var/log/mysqld.log | grep password

# 登陆
mysql -uroot -p

# 修改密码
alter user 'root'@'localhost' identified by '新密码';

# 允许root用户远程连接
use mysql;
update user set host='%' where user='root';

# 刷新
flush privileges;

#退出
exit

9. 开放3306端口

powershell 复制代码
# 防火墙添加3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent

# 重启防火墙
service firewalld restart

# 查看防火墙已开放端口
firewall-cmd --list-ports

10. 设置MySQL自启动

powershell 复制代码
# 开启自启
systemctl enable mysqld

# 刷新
systemctl daemon-reload

# 查看mysql是否自启,enabled为已开启
systemctl list-unit-files | grep mysqld
相关推荐
带土111 分钟前
33. 文件IO (4) 二进制文件操作与结构体存储 文件路径与目录操作
linux
无敌最俊朗@29 分钟前
C++音视频就业路线
linux·windows
Fr2ed0m37 分钟前
Linux 文本处理完整指南:grep、awk、sed、jq 命令详解与实战
linux·运维·服务器
大聪明-PLUS1 小时前
使用 GitLab CI/CD 为 Linux 创建 RPM 包(一)
linux·嵌入式·arm·smarc
边疆.1 小时前
【Linux】自动化构建工具make和Makefile和第一个系统程序—进度条
linux·运维·服务器·makefile·make
2021黑白灰1 小时前
windows11 vscode ssh远程linux服务器/虚拟机 免密登录
linux·服务器·ssh
z202305081 小时前
linux之PCIE 设备枚举流程分析
linux·运维·服务器
simple_whu1 小时前
编译tiff:arm64-linux-static报错 Could NOT find CMath (missing: CMath_pow)
linux·运维·c++
SundayBear2 小时前
Linux驱动开发指南
linux·驱动开发·嵌入式
大聪明-PLUS2 小时前
使用 GitLab CI/CD 为 Linux 构建 RPM 包(二)
linux·嵌入式·arm·smarc