美文网首页mysql
redhat7.3 yum安装mysql

redhat7.3 yum安装mysql

作者: CUFFS | 来源:发表于2018-07-11 13:25 被阅读45次

    参考官网

    https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html

    下载yum仓库安装文件

    https://dev.mysql.com/downloads/repo/yum/
    下载对应的yum rpm包,此过程需要登录oracle账号,获取下载连接

    wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
    [root@localhost home]# ls -la mysql80-community-release-el7-1.noarch.rpm 
    -rw-r--r--. 1 root root 25820 Apr 18 13:24 mysql80-community-release-el7-1.noarch.rpm
    [root@localhost home]# 
    
    

    安装yum仓库

    [root@localhost home]# yum localinstall mysql80-community-release-el7-1.noarch.rpm 
    Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Examining mysql80-community-release-el7-1.noarch.rpm: mysql80-community-release-el7-1.noarch
    Marking mysql80-community-release-el7-1.noarch.rpm to be installed
    Resolving Dependencies
    --> Running transaction check
    ---> Package mysql80-community-release.noarch 0:el7-1 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =============================================================================================================================================================
     Package                                    Arch                    Version                   Repository                                                Size
    =============================================================================================================================================================
    Installing:
     mysql80-community-release                  noarch                  el7-1                     /mysql80-community-release-el7-1.noarch                   31 k
    
    Transaction Summary
    =============================================================================================================================================================
    Install  1 Package
    
    Total size: 31 k
    Installed size: 31 k
    Is this ok [y/d/N]: y
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Warning: RPMDB altered outside of yum.
    ** Found 6 pre-existing rpmdb problem(s), 'yum check' output follows:
    ipa-admintools-4.4.0-12.el7.noarch has installed conflicts freeipa-admintools: ipa-admintools-4.4.0-12.el7.noarch
    ipa-client-4.4.0-12.el7.x86_64 has installed conflicts freeipa-client: ipa-client-4.4.0-12.el7.x86_64
    ipa-client-common-4.4.0-12.el7.noarch has installed conflicts freeipa-client-common: ipa-client-common-4.4.0-12.el7.noarch
    ipa-common-4.4.0-12.el7.noarch has installed conflicts freeipa-common: ipa-common-4.4.0-12.el7.noarch
    ipa-server-4.4.0-12.el7.x86_64 has installed conflicts freeipa-server: ipa-server-4.4.0-12.el7.x86_64
    ipa-server-common-4.4.0-12.el7.noarch has installed conflicts freeipa-server-common: ipa-server-common-4.4.0-12.el7.noarch
      Installing : mysql80-community-release-el7-1.noarch                                                                                                    1/1 
      Verifying  : mysql80-community-release-el7-1.noarch                                                                                                    1/1 
    
    Installed:
      mysql80-community-release.noarch 0:el7-1                                                                                                                   
    
    Complete!
    [root@localhost home]# yum repolist enabled | grep "mysql.*-community.*"
    

    允许mysql相关仓库

    [root@localhost home]# yum repolist enabled | grep "mysql.*-community.*"
    mysql-connectors-community/x86_64       MySQL Connectors Community        51
    mysql-tools-community/x86_64            MySQL Tools Community             63
    mysql80-community/x86_64                MySQL 8.0 Community Server        17
    [root@localhost home]# 
    
    

    查看mysql对应版本信息

    [root@localhost home]# yum repolist all | grep mysql
    mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community       disabled
    mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - Sou disabled
    mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community       disabled
    mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - Sou disabled
    mysql-connectors-community/x86_64  MySQL Connectors Community        enabled: 51
    mysql-connectors-community-source  MySQL Connectors Community - Sour disabled
    mysql-tools-community/x86_64       MySQL Tools Community             enabled: 63
    mysql-tools-community-source       MySQL Tools Community - Source    disabled
    mysql-tools-preview/x86_64         MySQL Tools Preview               disabled
    mysql-tools-preview-source         MySQL Tools Preview - Source      disabled
    mysql55-community/x86_64           MySQL 5.5 Community Server        disabled
    mysql55-community-source           MySQL 5.5 Community Server - Sour disabled
    mysql56-community/x86_64           MySQL 5.6 Community Server        disabled
    mysql56-community-source           MySQL 5.6 Community Server - Sour disabled
    mysql57-community/x86_64           MySQL 5.7 Community Server        disabled
    mysql57-community-source           MySQL 5.7 Community Server - Sour disabled
    mysql80-community/x86_64           MySQL 8.0 Community Server        enabled: 17
    mysql80-community-source           MySQL 8.0 Community Server - Sour disabled
    [root@localhost home]# 
    
    

    开启需要安装的版本

    默认开启mysql8.0版本,禁用8.0版本,启动5.7版本

    yum-config-manager --disable mysql80-community
    yum-config-manager --enable mysql57-community
    
    

    安装mysql5.7

    • 确认当前yum启动的版本
    [root@localhost home]# yum repolist enabled | grep mysql
    mysql-connectors-community/x86_64       MySQL Connectors Community         51
    mysql-tools-community/x86_64            MySQL Tools Community              63
    mysql57-community/x86_64                MySQL 5.7 Community Server        267
    [root@localhost home]# 
    
    
    • 安装mysql5.7
    [root@localhost home]# yum install mysql-community-server
    Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Resolving Dependencies
    --> Running transaction check
    ---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
    --> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
    ---> Package mysql-community-server.x86_64 0:5.7.22-1.el7 will be obsoleting
    --> Processing Dependency: mysql-community-common(x86-64) = 5.7.22-1.el7 for package: mysql-community-server-5.7.22-1.el7.x86_64
    --> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.22-1.el7.x86_64
    --> Running transaction check
    ---> Package mariadb.x86_64 1:5.5.52-1.el7 will be obsoleted
    ---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
    --> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
    ---> Package mysql-community-client.x86_64 0:5.7.22-1.el7 will be obsoleting
    --> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.22-1.el7.x86_64
    ---> Package mysql-community-common.x86_64 0:5.7.22-1.el7 will be installed
    --> Running transaction check
    ---> Package mariadb-libs.x86_64 1:5.5.52-1.el7 will be obsoleted
    --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: perl-DBD-MySQL-4.023-5.el7.x86_64
    --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:qt-mysql-4.8.5-13.el7.x86_64
    --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:net-snmp-5.7.2-24.el7_2.1.x86_64
    --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
    --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: perl-DBD-MySQL-4.023-5.el7.x86_64
    --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 1:qt-mysql-4.8.5-13.el7.x86_64
    --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
    ---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
    --> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
    ---> Package mysql-community-libs.x86_64 0:5.7.22-1.el7 will be obsoleting
    --> Running transaction check
    ---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be obsoleted
    --> Processing Dependency: mariadb-server for package: akonadi-mysql-1.9.2-4.el7.x86_64
    ---> Package mysql-community-libs-compat.x86_64 0:5.7.22-1.el7 will be obsoleting
    --> Finished Dependency Resolution
    Error: Package: akonadi-mysql-1.9.2-4.el7.x86_64 (@anaconda/7.3)
               Requires: mariadb-server
               Removing: 1:mariadb-server-5.5.52-1.el7.x86_64 (@anaconda/7.3)
                   mariadb-server = 1:5.5.52-1.el7
               Obsoleted By: mysql-community-server-5.7.22-1.el7.x86_64 (mysql57-community)
                   Not found
     You could try using --skip-broken to work around the problem
    ** Found 6 pre-existing rpmdb problem(s), 'yum check' output follows:
    ipa-admintools-4.4.0-12.el7.noarch has installed conflicts freeipa-admintools: ipa-admintools-4.4.0-12.el7.noarch
    ipa-client-4.4.0-12.el7.x86_64 has installed conflicts freeipa-client: ipa-client-4.4.0-12.el7.x86_64
    ipa-client-common-4.4.0-12.el7.noarch has installed conflicts freeipa-client-common: ipa-client-common-4.4.0-12.el7.noarch
    ipa-common-4.4.0-12.el7.noarch has installed conflicts freeipa-common: ipa-common-4.4.0-12.el7.noarch
    ipa-server-4.4.0-12.el7.x86_64 has installed conflicts freeipa-server: ipa-server-4.4.0-12.el7.x86_64
    ipa-server-common-4.4.0-12.el7.noarch has installed conflicts freeipa-server-common: ipa-server-common-4.4.0-12.el7.noarch
    
    

    发生报错:没有卸载mariadb

    [root@localhost home]# rpm -qa|grep mariadb
    mariadb-libs-5.5.52-1.el7.x86_64
    mariadb-5.5.52-1.el7.x86_64
    mariadb-server-5.5.52-1.el7.x86_64
    [root@localhost home]# 
    
    rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
    rpm -e --nodeps mariadb-5.5.52-1.el7.x86_64
    rpm -e --nodeps mariadb-server-5.5.52-1.el7.x86_64
    
    • 再次执行安装命令
    yum install mysql-community-server
    Installed:
      mysql-community-server.x86_64 0:5.7.22-1.el7                                                                                                               
    
    Dependency Installed:
      mysql-community-client.x86_64 0:5.7.22-1.el7        mysql-community-common.x86_64 0:5.7.22-1.el7        mysql-community-libs.x86_64 0:5.7.22-1.el7       
    
    Complete!
    
    

    查看msyql版本

    [root@localhost home]# systemctl start mysqld
    [root@localhost home]# mysql --version
    mysql  Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using  EditLine wrapper
    [root@localhost home]# 
    
    

    5.7版本默认生成了root密码

    grep 'temporary password' /var/log/mysqld.log
    

    修改mysql密码和远程登录

    mysql -uroot -p
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
    use mysql;
    update user set host='%' where user='root' and host='localhost';
    flush privileges;
    
    

    修改默认字符集

    /etc/my.cnf
    [mysqld]下面增加
    character-set-server=utf8
    重启mysql

    兼容5.6的一些设置

    character-set-server=utf8
    lower_case_table_names=1 #忽略大小写
    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    
    

    相关文章

      网友评论

        本文标题:redhat7.3 yum安装mysql

        本文链接:https://www.haomeiwen.com/subject/cpkhpftx.html