暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

0090.M CentOS7上mysql5.7 http yum源配置

rundba 2021-09-08
751

通过配置本地http 的mysql yum源,安装特定版本mysql。

0.ENV

CentOS7.7;

mysql 5.7.33。

1. 下载mysql

下载地址:

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

Select Version:5.7.33  OR 5.6.51

Select Operating System:RHEL/OEL

Select OS Version:RHEL7/OEL7

download “RPM Bundle”:登录ORACLE账号后进行下载

OR

直接下载:

    wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar

    [root@cdh1 soft]# du -sh mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar
    518M mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar
    复制

    2. 上传到服务器

    略。

    3. 安装mysql5.7

    解压mysql5.7安装包

      [root@cdp1 soft]# pwd
      /soft
      [root@cdh1 soft]# mkdir 5.7.33
      [root@cdh1 soft]# tar xvf mysql-5.7.33-1.el7.x86_64.rpm-bundle.tar -C 5.7.33
      mysql-community-client-5.7.33-1.el7.x86_64.rpm
      mysql-community-common-5.7.33-1.el7.x86_64.rpm
      mysql-community-devel-5.7.33-1.el7.x86_64.rpm
      mysql-community-embedded-5.7.33-1.el7.x86_64.rpm
      mysql-community-embedded-compat-5.7.33-1.el7.x86_64.rpm
      mysql-community-embedded-devel-5.7.33-1.el7.x86_64.rpm
      mysql-community-libs-5.7.33-1.el7.x86_64.rpm
      mysql-community-libs-compat-5.7.33-1.el7.x86_64.rpm
      mysql-community-server-5.7.33-1.el7.x86_64.rpm
      mysql-community-test-5.7.33-1.el7.x86_64.rpm
      复制

      4. 创建依赖关系

      安装 createrepo

        [root@cdp1 soft]# yum -y install createrepo
        复制

        建立yum源的依赖关系文件

          [root@cdp1 ~]# createrepo soft/5.7.33/      
          Spawning worker 0 with 2 pkgs
          Spawning worker 1 with 2 pkgs
          Spawning worker 2 with 1 pkgs
          Spawning worker 3 with 1 pkgs
          Spawning worker 4 with 1 pkgs
          Spawning worker 5 with 1 pkgs
          Spawning worker 6 with 1 pkgs
          Spawning worker 7 with 1 pkgs
          Workers Finished
          Saving Primary metadata
          Saving file lists metadata
          Saving other metadata
          Generating sqlite DBs
          Sqlite DBs complete
          复制

          5. http配置

          如果使用http作为输出

            [root@cdp1 ~]# yum -y install httpd
            [root@cdp1 ~]# systemctl enable httpd
            [root@cdp1 ~]# systemctl start httpd
            复制

            创建软链接

              [root@cdp1 ~]# ln -s soft/5.7.33/ var/www/html/mysql5.7.33
              复制

              创建配置文件

                # cat etc/yum.repos.d/cdp.repo
                [db]
                name=mysql5.7.33
                baseurl=http://192.168.80.70/mysql5.7.33
                enabled=1
                gpgcheck=0
                复制

                查看repolist配置

                  # yum repolist
                  复制

                  6. 后续安装配置

                  6.1 安装mysql

                  前述已经配置了mysql httpd yum源

                    [root@cdp1 ~]# yum install -y mysql-community-server
                    复制

                    6.2 修改配置

                      [root@cdp1 ~]# cp etc/my.cnf etc/my.cnf.orig
                      [root@cdp1 ~]# vim etc/my.cnf #配置内容
                      [mysqld]
                      character-set-server = utf8
                      collation-server = utf8_general_ci

                      datadir=/var/lib/mysql
                      socket=/var/lib/mysql/mysql.sock
                      transaction-isolation = READ-COMMITTED
                      # Disabling symbolic-links is recommended to prevent assorted security risks;
                      # to do so, uncomment this line:
                      symbolic-links = 0

                      key_buffer_size = 32M
                      max_allowed_packet = 16M
                      thread_stack = 256K
                      thread_cache_size = 64
                      # The following 3 parameters only apply to MySQL version 5.7 and lower:
                      query_cache_limit = 8M
                      query_cache_size = 64M
                      query_cache_type = 1

                      max_connections = 550

                      log_bin=/var/lib/mysql/mysql_binary_log
                      relay-log=/var/lib/mysql/relay-mysql
                      #In later versions of MySQL, if you enable the binary log and do not set
                      #a server_id, MySQL will not start. The server_id must be unique within
                      #the replicating group.
                      server_id=1
                      auto-increment-offset = 1
                      auto-increment-increment = 2

                      binlog_format = mixed

                      read_buffer_size = 2M
                      read_rnd_buffer_size = 16M
                      sort_buffer_size = 8M
                      join_buffer_size = 8M
                      # InnoDB settings
                      innodb_file_per_table = 1
                      innodb_flush_log_at_trx_commit = 2
                      innodb_log_buffer_size = 64M
                      innodb_buffer_pool_size = 4G
                      innodb_thread_concurrency = 8
                      innodb_flush_method = O_DIRECT
                      innodb_log_file_size = 512M
                      innodb_file_format = Barracuda
                      innodb_large_prefix = ON

                      [mysqld_safe]
                      log-error=/var/log/mysqld.log
                      pid-file=/var/run/mysqld/mysqld.pid
                      复制

                      6.3 启动mysql服务

                        [root@cdp1 ~]# systemctl start mysqld
                        [root@cdp1 ~]# systemctl enable mysqld
                        复制

                        6.4 重置mysql密码

                          [root@cdp1 ~]# mysql
                          ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
                          [root@cdp1 ~]# systemctl stop mysqld
                          复制


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

                          在[mysqld]段内最后添加

                            skip-grant-tables
                            复制

                            保存退出重启mysql服务


                              [root@cdp1 ~]# systemctl restart mysqld
                              [root@cdp1 ~]# mysql
                              mysql> use mysql
                              mysql> update user set authentication_string=password('Rundba_15') where user='root';




                              vim /etc/my.cnf #去掉参数
                              skip-grant-tables
                              复制


                              重启服务

                                [root@cdp1 ~]# systemctl restart mysqld
                                复制


                                6.5 登录数据库

                                [root@cdp1 ~]# mysql -uroot -pRundba_15


                                --完--

                                文章转载自rundba,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                                评论