linux上安装MySQL

2019-11-11 16:01:32来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

linux上安装MySQL

Posted on 2019-11-11 21:25 反射弧 阅读(...) 评论(...) 编辑 收藏

环境:centos7   mysql8.0.18

一、下载mysql服务软件包

  地址:https://dev.mysql.com/downloads/mysql/

  rpm package:是某个特定的包,比如server,client,devle等    
  rpm bundle:是该版本所有包的集合                                         
  Compressed TAR Archive,是源码,必须用源码方式安装  

  Compatibility Libraries:兼容库  

  Shared Libraries:共享库  

  Development Libraries:开发库  

  Test Suite:测试套件

  Client Utilities:客户端工具

  下载时注意选则好对应的版本

二、安装

  (1)rpm -ivh  mysql-community-libs-8.0.18-1.el7.x86_64

  报错信息:

  error: Failed dependencies:

  mariadb-libs is obsoleted by mysql-community-libs-8.0.18-1.el7.x86_64

  原因:mariadb-libs和 mysql-community-libs冲突

  解决办法:卸载mariadb-libs

  a.查询mariadb-libs的包名

  [root@izm5e8nyz28va3a786y465z src]# rpm -qa |grep mariadb

  mariadb-libs-5.5.64-1.el7.x86_64

  b.卸载该包

   [root@izm5e8nyz28va3a786y465z src]# rpm -ev mariadb-libs-5.5.64-1.el7.x86_64 

    error: Failed dependencies:

    libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-7.el7.x86_64
    libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-7.el7.x86_64

    报错原因:postfix是mariadb 的依赖包,要先卸载它

    [root@izm5e8nyz28va3a786y465z src]# rpm -qa |grep postfix

    postfix-2.10.1-7.el7.x86_64
    [root@izm5e8nyz28va3a786y465z src]# rpm -ev postfix-2.10.1-7.el7.x86_64
    error: Failed dependencies:
    /usr/sbin/sendmail is needed by (installed) redhat-lsb-core-4.1-27.el7.centos.1.x86_64
    [root@izm5e8nyz28va3a786y465z src]# rpm -qa |grep redhat-lsb
    redhat-lsb-core-4.1-27.el7.centos.1.x86_64
    redhat-lsb-submod-security-4.1-27.el7.centos.1.x86_64
    [root@izm5e8nyz28va3a786y465z src]# rpm -ev redhat-lsb-core-4.1-27.el7.centos.1.x86_64
    Preparing packages...
    redhat-lsb-core-4.1-27.el7.centos.1.x86_64

    [root@izm5e8nyz28va3a786y465z src]# rpm -ev postfix-2.10.1-7.el7.x86_64

    Preparing packages...
    postfix-2:2.10.1-7.el7.x86_64

    上述步骤成功卸载掉mariadb-libs的依赖
    [root@izm5e8nyz28va3a786y465z src]# rpm -ev mariadb-libs-5.5.64-1.el7.x86_64
    Preparing packages...
    mariadb-libs-1:5.5.64-1.el7.x86_64

    继续安装:

    [root@izm5e8nyz28va3a786y465z src]# rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
    warning: mysql-community-libs-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing... ################################# [100%]
    Updating / installing...
    1:mysql-community-libs-8.0.18-1.el7################################# [100%]

    mysql-community-libs-8.0.18-1.el7包安装成功

    (2) rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm

    (3) rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm

    (4) rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm 

      error: Failed dependencies:

      libaio.so.1()(64bit) is needed by mysql-community-server-8.0.18-1.el7.x86_64

      libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.0.18-1.el7.x86_64
      libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-8.0.18-1.el7.x86_64

      解决依赖关系:

      [root@izm5e8nyz28va3a786y465z src]# yum list |grep libaio

      libaio.i686 0.3.109-13.el7 base
      libaio.x86_64 0.3.109-13.el7 base
      libaio-devel.i686 0.3.109-13.el7 base
      libaio-devel.x86_64 0.3.109-13.el7 base

      查询到4个相关的依赖包,只需安装libaio.x86_64    libaio-devel.x86_64

      yum  -y install  libaio.x86_64    libaio-devel.x86_64

      [root@izm5e8nyz28va3a786y465z src]# rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm 

      warning: mysql-community-server-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
      Preparing... ################################# [100%]
      Updating / installing...
        1:mysql-community-server-8.0.18-1.e################################# [100%]

    (5)rpm -ivh mysql-community-devel-8.0.18-1.el7.x86_64.rpm 

      error: Failed dependencies:

      pkgconfig(openssl) is needed by mysql-community-devel-8.0.18-1.el7.x86_64

      解决依赖关系:

      yum  -y  install  openssl  openssl-devel

      [root@izm5e8nyz28va3a786y465z src]# rpm -ivh mysql-community-devel-8.0.18-1.el7.x86_64.rpm 

      warning: mysql-community-devel-8.0.18-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
      Preparing... ################################# [100%]
      Updating / installing...
      1:mysql-community-devel-8.0.18-1.el################################# [100%]

    至此Mysql安装成功

    小结:1. 卸载掉冲突组件  mariadb

        rpm -ev redhat-lsb-core-4.1-27.el7.centos.1.x86_64  postfix-2.10.1-7.el7.x86_64   mariadb-libs-5.5.64-1.el7.x86_64

       2.安装相关依赖:

        yum  -y  install  openssl  openssl-devel  libaio    libaio-devel

三、mysql服务设置

   1.启动mysql服务:systemctl start mysqld.service

    查看MySQL服务是否启动:netstat -tunpl |grep mysqld

    

   2.登录MySQL修改密码

    (1)登录mysql

    2种方法:跳过密码验证登录   或    查看初始密码登录

     a.查看初始密码登录

    cat  /var/log/mysqld.log

    ...   2019-11-11T14:28:57.523108Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ,2sg6>HrQdF!    

    标红加粗部分为初始密码    mysql -uroot  -p    键入密码可以登录MySQL

    b.跳过密码验证登录

    修改my.cnf文件,在[mysqld]区域下加入skip-grant-tables  重启MySQL

    [root@izm5e8nyz28va3a786y465z ~]# find / -name my.cnf
    /etc/my.cnf

    [root@izm5e8nyz28va3a786y465z ~]# vim /etc/my.cnf     

    [root@izm5e8nyz28va3a786y465z run]# systemctl restart mysqld.service

    [root@izm5e8nyz28va3a786y465z run]# mysql   #可直接登录MySQL

    注意:修改密码后,将my.cnf文件内容还原

    (2)修改密码

    


原文链接:https://www.cnblogs.com/fanshehu/p/11838596.html
如有疑问请与原作者联系

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Linux-CentOS-Nginx安装

下一篇:chrony服务配置