【Linux】【MySQL】安装MySQL,版本5.7

本文环境:CentOS7,安装包放在/home/mysql

https://downloads.mysql.com/archives/community/

下载地址:https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar

或者直接在Linux上wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar

1、安装新版mysql前,需将系统自带的mariadb-lib卸载,rpm -qa|grep mariadb

【Linux】【MySQL】安装MySQL,版本5.7

 

 rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64

【Linux】【MySQL】安装MySQL,版本5.7

 

 2、解压

cd /home/mysql

tar -xvf /home/mysql/mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar

【Linux】【MySQL】安装MySQL,版本5.7

 

 3、安装

rpm -ivh mysql-community-common-5.7.32-1.el7.x86_64.rpm

【Linux】【MySQL】安装MySQL,版本5.7

 

 rpm -ivh mysql-community-libs-5.7.32-1.el7.x86_64.rpm

【Linux】【MySQL】安装MySQL,版本5.7

 

 rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm

【Linux】【MySQL】安装MySQL,版本5.7

 

 rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm --force --nodeps

【Linux】【MySQL】安装MySQL,版本5.7

 

 注:如果不带 --force --nodeps,可能发生下面错误

【Linux】【MySQL】安装MySQL,版本5.7

 

 4、修改配置文件t添加下面内容,vi /etc/my.cnf

skip-grant-tables
character_set_server=utf8
init_connect=‘SET NAMES utf8‘

【Linux】【MySQL】安装MySQL,版本5.7

 

说明:

skip-grant-tables:跳过登录验证

character_set_server=utf8:设置默认字符集UTF-8

init_connect=‘SET NAMES utf8‘:设置默认字符集UTF-8

5、启动服务

设置开机启动

【Linux】【MySQL】安装MySQL,版本5.7

 

 进入mysql,mysql

【Linux】【MySQL】安装MySQL,版本5.7

 

 6、设置密码,update mysql.user set authentication_string=password(‘123456‘) where user=‘root‘;

刷新权限,flush privileges;

【Linux】【MySQL】安装MySQL,版本5.7

7、退出mysql,重启mysql

exit;

systemctl stop mysqld.service

systemctl start mysqld.service

【Linux】【MySQL】安装MySQL,版本5.7

 

 8、重新连接mysql,mysql -uroot -p123456

【Linux】【MySQL】安装MySQL,版本5.7

 

 

参考文章:https://www.cnblogs.com/raicho/p/12511998.html

【Linux】【MySQL】安装MySQL,版本5.7

上一篇:mysql8 执行SQL语句报错 "this is incompatible with sql_mode=only_full_group_by"


下一篇:Mongodb安装使用