相关安装命令如下:
mysql repo-rpm 各个版本的下载地址
http://repo.mysql.com/
#查看是否安装了旧版本的数据库,并卸载
rpm -qa | grep mysql
rpm -qa | grep -i mariadb
#删除以前的mysql文件
rm -rf /var/lib/mysql
#卸载mysql相关repo包
#想用哪个版本的就下载哪个版本的repo包
#Center OS 7版本
#下载5.6版本的repo包
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -Uvh mysql-community-release-el7-5.noarch.rpm
#Center OS 7版本
#下载5.7版本的repo包
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -Uvh mysql57-community-release-el7-9.noarch.rpm
#Center OS 7版本
#下载8.0版本的mysql repo包
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
#Center OS 5版本
#下载5.7版本的repo包
wget https://dev.mysql.com/get/mysql57-community-release-el5.rpm
rpm -Uvh mysql57-community-release-el5.rpm
#Center OS 6版本
#下载5.7版本的repo包
wget https://dev.mysql.com/get/mysql57-community-release-el6.rpm
rpm -Uvh mysql57-community-release-el6.rpm
#查看mysql版本
rpm -qa | grep mysql-community-server
#确认版本正确后安装mysql
yum -y install mysql-community-server
#手动rpm方式安装5.6
wget https://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.49-1.el7.x86_64.rpm-bundle.tar
tar xvf MySQL-5.6.49-1.el7.x86_64.rpm-bundle.tar
rpm -ivh MySQL*.rpm
#service mysql start
#centos 8 安装mysql80 server
wget http://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm
rpm -ivh mysql80-community-release-el8-1.noarch.rpm
yum repolist enabled | grep "mysql.*-community.*"
yum module disable mysql
#如果提示依赖问题,卸载即可
rpm -e mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64
yum install mysql-community-server
启动
service mysqld start
#查看原始密码
cat /var/log/mysqld.log | grep password
#修改默认密码
mysqladmin -u root -p password "sho0pqFIi#HQ"
#可能在授权用户时会提示
the server requested authentication method unknown to the client
#解决方法=找到mysql配置文件并加入
default_authentication_plugin=mysql_native_password
执行命令
ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 's0pqFIi#HQ';