Centos7.9安装MYSQL数据库

下载MySQL8.0.31

官方下载地址:https://downloads.mysql.com/archives/community/

MySQL8.0.31下载地址:https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar

注意,由于是Centos 7 ,就下载Linux 7

部署

上传文件

[root@vmmrgcentos itools]# pwd
/usr/itools
[root@vmmrgcentos itools]# ll
total 884872
-rw-r--r-- 1 root root 906106880 Jun  5 10:36 mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar

解压mysql文件

[root@vmmrgcentos itools]# tar -xvf mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar 
mysql-community-client-8.0.31-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
mysql-community-common-8.0.31-1.el7.x86_64.rpm
mysql-community-debuginfo-8.0.31-1.el7.x86_64.rpm
mysql-community-devel-8.0.31-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.31-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
mysql-community-libs-8.0.31-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.31-1.el7.x86_64.rpm
mysql-community-server-8.0.31-1.el7.x86_64.rpm
mysql-community-server-debug-8.0.31-1.el7.x86_64.rpm
mysql-community-test-8.0.31-1.el7.x86_64.rpm
[root@vmmrgcentos itools]# 

执行安装

# 由于 MySQL 安装过程中,会通过 MySQL 用户在 /tmp 目录下新建 tmp_db 文件。赋予其权限执行:
chmod -R 777 /tmp
# 检查依赖是否存在(CentOS7安装了桌面环境默认存在)
rpm -qa|grep libaio
rpm -qa|grep net-tools
# MySQL 与 mysql-libs 冲突,提前移除
yum remove mysql-libs 或者 rpm -e mariadb-libs --nodeps
 
# 执行安装(严格按照顺序)
rpm -ivh mysql-community-common-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.31-1.el7.x86_64.rpm
注意:若部署过程遇缺少.so的依赖
[root@vmmrgcentos itools]# rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpm 
警告:mysql-community-libs-8.0.31-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY 
错误:依赖检测失败: mariadb-libs 被 mysql-community-libs-8.0.31-1.el7.x86_64 取代 
[root@vmmrgcentos itools]# rpm -e mariadb-libs --nodeps # 卸载mariadb-libs 
[root@vmmrgcentos itools]# rpm -ivh mysql-community-server-8.0.31-1.el7.x86_64.rpm 
警告:mysql-community-server-8.0.31-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY 
错误:依赖检测失败: net-tools 被 mysql-community-server-8.0.31-1.el7.x86_64 需要 
[root@vmmrgcentos itools]# yum install -y net-tools

防火墙配置

# 关闭本机及远程主机防火墙或开放端口号 
# Linux 下防火墙设置
# 查看防火墙状态
systemctl status firewalld
# 开启3306端口 
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# 重启防火墙 
firewall-cmd --reload
# 列出所有添加的防火墙规则 
firewall-cmd --list-all

简单配置

# 查看是否安装成功
mysql --version
# root用户下进行初始化
mysqld --initialize --user=mysql
# 查看初始密码
cat /var/log/mysqld.log
# 启动 MySQL
systemctl start mysqld
# 查看状态
systemctl status mysqld
# 查看 MySQL 自启动状态
systemctl list-unit-files|grep mysqld.service
# enable 为自启动打开,disable 为自启动关闭
# systemctl enable mysqld(将某服务设置为自启动状态)
# systemctl disable mysqld(将某服务设置为自启动状态)

# 登录 MySQL
mysql -uroot -p
# 修改初始密码(root'@'localhost),如果不修改的密码,其他操作包括修改root'@'%,一切命令都不好使
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

 

THE END
分享
二维码
打赏
海报
Centos7.9安装MYSQL数据库
下载MySQL8.0.31 官方下载地址:https://downloads.mysql.com/archives/community/ MySQL8.0.31下载地址:https://cdn.mysql.com/archives/mysql-8.0/mysql-8.……
<<上一篇
下一篇>>