CentOS7 离线编译安装Mysql5.7

First

下载Mysql-5.7的rpm-bundle版本,并使用xftp或者flashftp等工具上传到CentOS上

在这里插入图片描述

Second

tar xvf mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar ,解压后会有很多rpm包,如下所示

mysql-community-client-5.7.23-1.el7.x86_64.rpm
mysql-community-common-5.7.23-1.el7.x86_64.rpm
mysql-community-devel-5.7.23-1.el7.x86_64.rpm
mysql-community-embedded-5.7.23-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.23-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.23-1.el7.x86_64.rpm
mysql-community-libs-5.7.23-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.23-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.23-1.el7.x86_64.rpm
mysql-community-server-5.7.23-1.el7.x86_64.rpm
mysql-community-server-minimal-5.7.23-1.el7.x86_64.rpm
mysql-community-test-5.7.23-1.el7.x86_64.rpm

Third

rpm -ivh mysql-community-server-5.7.23-1.el7.x86_64.rpm --nodeps ,忽略依赖关系分别安装上面的包,其中server和server-minimal冲突,只安装server即可。安装成果反应如下:

[root@epaper mysql57]# rpm -ivh mysql-community-server-5.7.23-1.el7.x86_64.rpm --nodeps
warning: mysql-community-server-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.23-1.e################################# [100%]
[root@epaper mysql57]# rpm -ivh mysql-community-client-5.7.23-1.el7.x86_64.rpm --nodeps
warning: mysql-community-client-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.23-1.e################################# [100%]
[root@epaper mysql57]# rpm -ivh mysql-community-libs-5.7.23-1.el7.x86_64.rpm --nodeps
warning: mysql-community-libs-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.23-1.el7################################# [100%]
[root@epaper mysql57]# rpm -ivh mysql-community-libs-compat-5.7.23-1.el7.x86_64.rpm  --nodeps
warning: mysql-community-libs-compat-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-compat-5.7.2################################# [100%]

安装后可以通过,rpm -q 包名来查看是否安装上了,这里有关rpm的命令推荐一篇文章《centos7 RPM包之rpm命令》

[tips]安装过程中,可能会遇到conflict 报错,比如下面:

[root@epaper mysql57]# rpm -ivh mysql-community-server-5.7.23-1.el7.x86_64.rpm --nodeps
warning: mysql-community-server-5.7.23-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
 file /etc/my.cnf from install of mysql-community-server-5.7.23-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.52-1.el7.x86_64

这是提示你系统中原来的包和你现在安装的包冲突了,那么你需要先卸载掉原来的包yum -y remove mariadb-libs.x86_64,再来安装现在的包

Four

初始化mysql,systemctl start mysqld,MySQL自动会在/var/log/mysqld.log中随机生成一个root@localhost密码,grep 'password' /var/log/mysqld.log,返回如下:

2018-10-18T05:30:58.336743Z 0 [Note] Shutting down plugin 'sha256_password'
2018-10-18T05:30:58.336749Z 0 [Note] Shutting down plugin 'mysql_native_password'
2018-10-18T05:31:28.958031Z 0 [Note] Shutting down plugin 'sha256_password'
2018-10-18T05:31:28.958043Z 0 [Note] Shutting down plugin 'mysql_native_password'
2018-10-18T05:41:37.082893Z 0 [Note] Shutting down plugin 'sha256_password'
2018-10-18T05:41:37.082900Z 0 [Note] Shutting down plugin 'mysql_native_password'
2018-10-18T05:48:59.273589Z 1 [Note] A temporary password is generated for root@localhost: gs<7CafauqzL

这里我的随机密码为gs<7CafauqzL

[tips]这里可能会出现没有temporary password的情况,又可能是你的历史残留文件导致MySQL以为已经初始化过了,所以rm -rf /var/lib/mysql,删掉历史文件,重启mysqld即可以初始化成功

Five

mysql -uroot -p ,使用随机密码登陆,首次登陆必须修改密码,否则不能进行任何数据操作

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

此处提示,必须先重置密码

Six

alter user root@localhost identified by ‘your pwd’

需要注意的是,这里密码必须为含有大小写字母、符号和数字的组合,才可以重置成功

发布了65 篇原创文章 · 获赞 58 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/AngelLover2017/article/details/83146070
今日推荐