文章插图
文章插图
最近在学习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.repocurl -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的版本,右键选择复制地址
4.开始下载rpm文件
wget https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-server-5.7.35-1.el7.x86_64.rpm
可以看到阿里的下载速度还是很快的,6MB/S的下载速度5.安装mysql
rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm
安装提示有错误rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpmwarning: mysql-community-server-5.7.35-1.el7.x86_64.rpm: Header V3 DSA/SHA256 Signature, key ID 5072e1f5: NOKEYerror: Failed dependencies:mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.35-1.el7.x86_64mysql-community-common(x86-64) = 5.7.35-1.el7 is needed by mysql-community-server-5.7.35-1.el7.x86_64net-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.rpmrpm -ivh https://mirrors.aliyun.com/mysql/MySQL-5.7/mysql-community-libs-5.7.35-1.el7.x86_64.rpmrpm -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 mariadbmariadb-libs-5.5.65-1.el7.x86_64yum remove mariadb-libs-5.5.65-1.el7.x86_64
删除完后继续安装上面的几个依赖包
安装完以后就可以安装最开始那个rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm
安装进度
进度跳走完我们的mysql已经安装完了
第四步:开启mysql并做配置
启动mysql服务并设置开机启动
systemctl start mysqld
查看mysql状态systemctl status mysqld
mysql已经正常在运行了
设置开机自动启动
chkconfig mysqld on
获取mysql的临时密码grep "password" /var/log/mysqld.log
红框里的就是临时密码
使用临时密码登录
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
设置字符集为utf-8查询 mysql 字符集:
show variables like 'chara%';
编辑 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下载安装教程 mysql下载及安装教程】重启mysql服务:systemctl restart mysqld
- 免费的音乐播放器哪个好 免费下载音乐播放器哪个好
- 部落冲突宝石修改器免费版苹果版 部落冲突宝石修改器下载
- google服务框架安装失败 google服务框架安装器
- 如何安装wifi教程 wifi怎么安装步骤
- 驱动盘怎么安装驱动 如何安装驱动盘
- 苹果平板安装外来软件 ipad怎么安装其他软件
- 快捷方式软件下载 快捷应用管理
- 阿里矢量图标怎么下载 阿里云矢量图标使用方法
- 手机谷歌浏览器为什么安装不了 手机谷歌浏览器下载安装不了
- hash文件工具怎么用 hash工具下载