1、下载地址:MySQL :: Download MySQL Community Server
2、点击下图Archives ,查看历史版本
(1)查询
# 查询带有mariadb的文件
rpm -qa | grep mariadb
(2)卸载
#强制卸载mariadb(-e为卸载。添加--nodeps为不检测以来卸载,也就是强制卸载)
rpm -e --nodeps mariadb*
rpm -qa | grep mysql
rpm -e --nodeps 文件名
1、解压刚刚下载的tar包到 /opt/下,得到rpm包
tar -xf mysql-5.7.41-1.el7.x86_64.rpm-bundle.tar -C /opt/
rpm -ivh mysql-community-common-5.7.41-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.41-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.41-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.41-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.41-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.41-1.el7.x86_64.rpm
注意:
(1)当执行到rpm -ivh mysql-community-libs-5.7.41-1.el7.x86_64.rpm 出现错误:依赖检测失败:mariadb-libs 被 mysql-community-libs-5.7.41-1.el7.x86_64 取代错误时,执行下面命令:
yum remove mysql-libs
(2)当执行rpm -ivh mysql-community-server-5.7.41-1.el7.x86_64.rpm出现:
错误:依赖检测失败:
/usr/bin/perl 被 mysql-community-server-5.7.41-1.el7.x86_64 需要
net-tools 被 mysql-community-server-5.7.41-1.el7.x86_64 需要
perl(Getopt::Long) 被 mysql-community-server-5.7.41-1.el7.x86_64 需要
perl(strict) 被 mysql-community-server-5.7.41-1.el7.x86_64 需要
执行:
yum install net-tools
yum install -y perl-Module-Install.noarch
然后重新进行安装:
rpm -ivh mysql-community-server-5.7.41-1.el7.x86_64.rpm
systemctl start mysqld
systemctl status mysqld
grep "password" /var/log/mysqld.log
(1)进入数据库:
mysql -u root -p
输入刚才找到的密码
(2)修改root账号密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
注意:其中‘new password’替换成你要设置的密码,注意:密码设置必须要大小写字母数字和特殊符号(,/';:等),不然不能配置成功
修改后再执行下面两条命令
flush privileges;
exit;
(3)开启MySQL的远程访问
grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;
注意:执行以下命令开启远程访问限制(注意:下面命令开启的IP是 192.168.0.1,如要开启所有的,用%代替IP)
修改后再执行下面两条命令
flush privileges;
exit;
(1)修改配置文件
vim /etc/my.cnf
(2) 添加下面配置
character_set_server = utf8
lower_case_table_names = 1
重启mysql服务使配置生效
systemctl restart mysqld