美文网首页
5.7二进制安装

5.7二进制安装

作者: 古飞_数据 | 来源:发表于2023-10-16 08:48 被阅读0次
    1 查看软件版本
    [root@localhost ~]# cat /etc/redhat-release
    CentOS Linux release 7.6.1810 (Core)
    
    yum install -y wget
    wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.33-el7-x86_64.tar
    2 卸载之前版本的Mariadb和 MySQL
    
    rpm -qa|grep -i mariadb
    rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
    rpm -qa |grep mysql
    
    rpm -qa| grep mysql | xargs rpm -e --nodeps
    rpm -qa| grep mariadb | xargs rpm -e --nodeps
    rpm -qa| grep mysql
    rpm -qa| grep mariadb
    
    
    
    sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
    cat /etc/selinux/config
    setenforce 0
    getenforce
    systemctl stop firewalld.service && systemctl disable firewalld && systemctl status firewalld
    
    
    3 安装mysql依赖包
    
    yum install -y libaio net-tools tree
    
    4 解压mysql 文件到/usr/local/mysql
    [root@localhost ~]# tar xf mysql-5.7.33-el7-x86_64.tar
    [root@localhost ~]# tar xf mysql-5.7.33-el7-x86_64.tar.gz -C /usr/local/
    cd /usr/local/
    [root@localhost local]# ln -sf mysql-5.7.33-el7-x86_64 mysql
    
    5 添加系统mysql组和mysql用户并修改权限
    
    [root@localhost local]# groupadd mysql
    [root@localhost local]# useradd -g mysql mysql
    chown -R mysql:mysql /usr/local/mysql-5.7.33-el7-x86_64/
    chown -R mysql:mysql /usr/local/mysql
    
    
    6 配置my.cnf文件
    
    mkdir -p /mysql/{data,log}
    chown -R mysql:mysql /mysql
    
    [root@localhost local]# /usr/local/mysql/bin/mysql --help --verbose | grep my.cnf
                          order of preference, my.cnf, $MYSQL_TCP_PORT,
    /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
    
    vi /etc/my.cnf
    [mysqld]
    # basic settings #
    user = mysql
    port = 3306
    sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
    autocommit = 1
    server-id = 1
    character_set_server = utf8mb4
    transaction_isolation = READ-COMMITTED
    lower_case_table_names = 1
    explicit_defaults_for_timestamp = 1
    max_allowed_packet = 16777216
    event_scheduler = 1
    basedir = /usr/local/mysql
    datadir = /mysql/data
    socket = /tmp/mysql.sock
    pid-file = /mysql/data/mysqld.pid
    
    # connection #
    interactive_timeout = 1800
    wait_timeout = 1800
    lock_wait_timeout = 1800
    skip_name_resolve = 1
    max_connections = 1000
    max_connect_errors = 1000000
    
    # table cache performance settings #
    table_open_cache = 4096
    table_definition_cache = 4096
    table_open_cache_instances = 64
    
    # log settings #
    log_error = /mysql/log/error.log
    slow_query_log_file = /mysql/log/slow.log
    log-bin = /mysql/log/mysql-bin
    relay_log = mysql-relay-bin
    general_log_file = general.log
    
    slow_query_log = 1
    log_queries_not_using_indexes = 1
    log_slow_admin_statements = 1
    log_slow_slave_statements = 1
    log_throttle_queries_not_using_indexes = 10
    long_query_time = 1
    min_examined_row_limit = 100
    binlog-rows-query-log-events = 1
    log-bin-trust-function-creators = 1
    expire-logs-days = 7
    log-slave-updates = 1
    
    # replication settings #
    master_info_repository = TABLE
    relay_log_info_repository = TABLE
    sync_binlog = 1
    gtid_mode = on
    enforce_gtid_consistency = 1
    log_slave_updates
    binlog_format = ROW
    binlog_rows_query_log_events = 1
    relay_log = relay.log
    relay_log_recovery = 1
    slave_skip_errors = ddl_exist_errors
    slave-rows-search-algorithms = 'INDEX_SCAN,HASH_SCAN'
    
    replicate-ignore-db = mysql
    replicate-ignore-db = information_schema
    replicate-ignore-db = performance_schema
    replicate-ignore-db = sys
    
    
    [mysqld-5.7]
    # new innodb settings #
    loose_innodb_numa_interleave = 1
    innodb_buffer_pool_dump_pct = 40
    innodb_page_cleaners = 16
    innodb_undo_log_truncate = 1
    innodb_max_undo_log_size = 2G
    innodb_purge_rseg_truncate_frequency = 128
    
    # new replication settings #
    slave-parallel-type = LOGICAL_CLOCK
    slave-parallel-workers = 16
    slave_preserve_commit_order = 1
    slave_transaction_retries = 128
    
    # other change settings #
    binlog_gtid_simple_recovery = 1
    log_timestamps = system
    show_compatibility_56 = on
    
    
    
    7 配置环境变量
    vi /etc/profile
    
    export MYSQL_HOME=/usr/local/mysql
    export PATH=$MYSQL_HOME/bin:$PATH
    source /etc/profile
    
    8 初始化数据库
    
    mysqld --defaults-file=/etc/my.cnf  --initialize
    cat /mysql/log/error.log
    
    )b)fkL28uvnp
    
    
    9 配置开机自启动
    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
    
    vi /etc/init.d/mysqld
    basedir=/usr/local/mysql
    datadir=/mysql/data
    
    chmod a+x /etc/init.d/mysqld
    chkconfig --add mysqld
    chkconfig --list
    
    10 启动mysql服务并初始化密码
    
    service mysqld start
    
    mysql -uroot -p
    alter user user() identified by '123';
    
    create database cndba;
    

    相关文章

      网友评论

          本文标题:5.7二进制安装

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