mysql最新版下载安装教程(安装mysql详细步骤)

最近在学习prometheus (普罗米修斯)监控主机、mysql、redis、容器等实操,今天在学习prometheus如何监控mysql主从库实操,在安装mysql数据库的时候发现网上很多教程的mysql在线安装地址要么超时要么已经不能使用,因为之前我centos7 的yum仓库地址已经改成阿里云的镜像站了,所以我试着从阿里云的镜像站下载安装mysql应该是最快的。

本篇就是根据自己的实际操作写的在阿里云yum下载安装你的mysql数据库

操作系统:centos 7

数据库版本:mysql5.7

第一步:更换yum源为阿里云yum

1.备份原始的CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2.下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

centos7 如果wget命令不能使用可以curl命令去下载,2个命令选一个执行即可

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

3、更新本地缓存

yum clean all

yum makecache

第二步:查看删除系统已安装的mysql数据库防止冲突

1.查看系统中是否自带安装mysql

yum list installed | grep mysql

2.删除系统自带的mysql及其依赖(防止冲突)

yum -y remove + 文件名

第三步:下载mysql数据库版本安装

1.如果你的centos没有wget命令可以先安装

yum install wget -y

2.到阿里云镜像站选择自己的mysql版本然后选择下载对应的rpm文件

MySQL版本

3.我这边选择安装mysql5.7.3.5的版本,右键选择复制地址

mysql5.7安装教程解决下载慢超时问题

4.开始下载rpm文件

wget https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-server-5.7.35-1.el7.x86_64.rpm
mysql5.7安装教程解决下载慢超时问题

可以看到阿里的下载速度还是很快的,6MB/S的下载速度

5.安装mysql

rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm

安装提示有错误

mysql5.7安装教程解决下载慢超时问题
rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.35-1.el7.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.35-1.el7.x86_64
        mysql-community-common(x86-64) = 5.7.35-1.el7 is needed by mysql-community-server-5.7.35-1.el7.x86_64
        net-tools is needed by mysql-community-server-5.7.35-1.el7.x86_64

主要就是提示缺少依赖,那我们就把相应的依赖包也一并下载下来

mysql-community-libs-5.7.35-1.el7.x86_64.rpm

mysql-community-client-5.7.35-1.el7.x86_64.rpm

mysql-community-common-5.7.35-1.el7.x86_64.rpm

net-tools

先安装net-tools 你可以直接使用yum -y install net-tools 直接安装

开始安装依赖包:

rpm -ivh https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-common-5.7.35-1.el7.x86_64.rpm
rpm -ivh https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-libs-5.7.35-1.el7.x86_64.rpm
rpm -ivh https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-client-5.7.35-1.el7.x86_64.rpm

在安装依赖的时候可能会提示跟mariadb-libs 的库文件冲突,我们先删除系统里的mariadb数据库

删除mariadb

rpm -qa |grep mariadb
mariadb-libs-5.5.65-1.el7.x86_64
yum remove mariadb-libs-5.5.65-1.el7.x86_64
删除完后继续安装上面的几个依赖包

安装完以后就可以安装最开始那个

rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm
mysql5.7安装教程解决下载慢超时问题

安装进度

进度跳走完我们的mysql已经安装完了

第四步:开启mysql并做配置

启动mysql服务并设置开机启动

systemctl start mysqld

查看mysql状态

systemctl status mysqld
mysql5.7安装教程解决下载慢超时问题

mysql已经正常在运行了

设置开机自动启动

chkconfig mysqld on

获取mysql的临时密码

grep "password" /var/log/mysqld.log
mysql5.7安装教程解决下载慢超时问题

红框里的就是临时密码

使用临时密码登录

mysql5.7安装教程解决下载慢超时问题

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';

设置字符集为utf-8

查询 mysql 字符集:

show variables like 'chara%';
mysql5.7安装教程解决下载慢超时问题

编辑 my.cnf 文件:vim /etc/my.cnf

[client]
  default-character-set=utf8

[mysqld]

# # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid default-storage-engine=INNODB character-set-server=utf8 collation-server=utf8_general_ci

保存退出后重启mysql

重启mysql服务:systemctl restart mysqld

版权声明:本站部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系运营社,如若转载,请注明出处:https://www.seozhh.com/15549.html

(0)
打赏 微信扫一扫 微信扫一扫
小茗的头像小茗认证作者

相关推荐

发表回复

登录后才能评论