centos7.3中RPM方式安装mysql5.7

前端之家收集整理的这篇文章主要介绍了centos7.3中RPM方式安装mysql5.7前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

首先去下载rpm安装包:https://dev.mysql.com/downloa...,选择红帽linux64位版。然后上传到服务器中。

[root@cs MysqL]# ls
MysqL-community-client-5.7.20-1.el7.x86_64.rpm  MysqL-community-embedded-5.7.20-1.el7.x86_64.rpm         MysqL-community-libs-5.7.20-1.el7.x86_64.rpm               MysqL-community-server-5.7.20-1.el7.x86_64.rpm
MysqL-community-common-5.7.20-1.el7.x86_64.rpm  MysqL-community-embedded-compat-5.7.20-1.el7.x86_64.rpm  MysqL-community-libs-compat-5.7.20-1.el7.x86_64.rpm        MysqL-community-server-minimal-5.7.20-1.el7.x86_64.rpm
MysqL-community-devel-5.7.20-1.el7.x86_64.rpm   MysqL-community-embedded-devel-5.7.20-1.el7.x86_64.rpm   MysqL-community-minimal-debuginfo-5.7.20-1.el7.x86_64.rpm  MysqL-community-test-5.7.20-1.el7.x86_64.rpm

接下来就是安装了,如果是普通用户需要sudo权限,并在执行命令前加sudo。如果安装过MysqL先用命令卸载掉相关的包。rpm安装是有依赖关系的所以我们要按照顺序进行安装:

[root@cs MysqL]# rpm -ivh MysqL-community-common-5.7.20-1.el7.x86_64.rpm 
warning: MysqL-community-common-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
    file /usr/share/MysqL/czech/errmsg.sys from install of MysqL-community-common-5.7.20-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.52-1.el7.x86_64

提示和我们安装的有冲突,我们找到这个包并卸载掉:

[root@cs MysqL]# rpm -qa|grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@cs MysqL]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

再次安装:

[root@cs MysqL]# rpm -ivh MysqL-community-common-5.7.20-1.el7.x86_64.rpm 
warning: MysqL-community-common-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MysqL-community-common-5.7.20-1.e################################# [100%]
[root@cs MysqL]# rpm -ivh MysqL-community-libs-5.7.20-1.el7.x86_64.rpm 
warning: MysqL-community-libs-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MysqL-community-libs-5.7.20-1.el7################################# [100%]
[root@cs MysqL]# rpm -ivh MysqL-community-client-5.7.20-1.el7.x86_64.rpm 
warning: MysqL-community-client-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MysqL-community-client-5.7.20-1.e################################# [100%]
[root@cs MysqL]# rpm -ivh MysqL-community-client-5.7.20-1.el7.x86_64.rpm 
warning: MysqL-community-client-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MysqL-community-client-5.7.20-1.e################################# [100%]
[root@cs MysqL]# rpm -ivh MysqL-community-server-5.7.20-1.el7.x86_64.rpm 
warning: MysqL-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY
error: Failed dependencies:
    libaio.so.1()(64bit) is needed by MysqL-community-server-5.7.20-1.el7.x86_64
    libaio.so.1(LIBAIO_0.1)(64bit) is needed by MysqL-community-server-5.7.20-1.el7.x86_64
    libaio.so.1(LIBAIO_0.4)(64bit) is needed by MysqL-community-server-5.7.20-1.el7.x86_64

提示安装失败,这是因为我们少这个依赖库,用yum进行安装:

[root@cs MysqL]# yum install libaio
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================================================
 Package                                                         Arch                                                            Version                                                                  Repository                                                     Size
==============================================================================================================================================================================================================================================================================
Installing:
 libaio                                                          x86_64                                                          0.3.109-13.el7                                                           base                                                           24 k

Transaction Summary
==============================================================================================================================================================================================================================================================================
Install  1 Package

Total download size: 24 k
Installed size: 38 k
Is this ok [y/d/N]: y
Downloading packages:
libaio-0.3.109-13.el7.x86_64.rpm                                                                                                                                                                                                                       |  24 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s),'yum check' output follows:
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libMysqLclient.so.18()(64bit)
2:postfix-2.10.1-6.el7.x86_64 has missing requires of libMysqLclient.so.18(libMysqLclient_18)(64bit)
  Installing : libaio-0.3.109-13.el7.x86_64                                                                                                                                                                                                                               1/1 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                                                                                                                                                                                               1/1 

Installed:
  libaio.x86_64 0:0.3.109-13.el7                                                                                                                                                                                                                                              

Complete!

再次安装:

[root@cs MysqL]# rpm -ivh MysqL-community-server-5.7.20-1.el7.x86_64.rpm 
warning: MysqL-community-server-5.7.20-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MysqL-community-server-5.7.20-1.e################################# [100%]
[root@cs MysqL]# rpm -ivh MysqL-community-libs-compat-5.7.20-1.el7.x86_64.rpm 
warning: MysqL-community-libs-compat-5.7.20-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%]

到此,安装完成。然后我们进行初始化数据库,因为我是root安装的所以想要指定一个MysqL用,用MysqL启动。根据自己的需要也可以不加。初始化:

[root@cs MysqL]# MysqLd --initialize --user=MysqL

启动数据库并:

[root@cs MysqL]# systemctl start MysqLd

设置开机自动启动并查看是否设置成功:

[root@cs MysqL]# systemctl enable MysqLd
[root@cs MysqL]# systemctl is-enabled MysqLd
enabled

因为MysqL5.7的会有一个随机密码在日志中生成,我们查找一下,密码这语句的最后:

[root@cs MysqL]# grep 'temporary password' /var/log/MysqLd.log
2017-11-17T08:05:05.411354Z 1 [Note] A temporary password is generated for root@localhost: Ret6HK7sab<a

然后我们就可以用密码登陆数据库,并修改密码增加远程访问权限了:

set password for 'root'@'localhost'=password('666666');
GRANT ALL PRIVILEGES ON *.* TO 'name'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;FLUSH PRIVILEGES;

小写部分为修改密码;大写部分为设置远程登陆权限。大功告成!

原文链接:https://www.f2er.com/centos/375249.html

猜你在找的CentOS相关文章