美文网首页
CentOS 8 MariaDB 10.6.14 二进制安装

CentOS 8 MariaDB 10.6.14 二进制安装

作者: 炸鱼最好吃 | 来源:发表于2023-07-14 15:17 被阅读0次

    下载安装包

    wget https://mirrors.ustc.edu.cn/mariadb/mariadb-10.6.14/bintar-linux-systemd-x86_64/mariadb-10.6.14-linux-systemd-x86_64.tar.gz
    

    解压

    tar xvf mariadb-10.6.14-linux-systemd-x86_64.tar.gz
    

    移动至/opt

    mv mariadb-10.6.14-linux-systemd-x86_64 /opt/mariadb
    

    初始化配置文件

    echo '!includedir /etc/my.cnf.d' > /etc/my.cnf
    mkdir /etc/my.cnf.d
    cat <<eof|tee /etc/my.cnf.d/server.cnf
    [mysqld]
    #base
    user=mysql
    port=3306
    basedir=/opt/mariadb
    datadir=/opt/mariadb/data
    socket=/opt/mariadb/data/mysql.socket
    pid-file=/opt/mariadb/data/mysqld.pid
    
    #log
    log_error=/opt/mariadb/log/mariadb.log
    slow_query_log=on
    slow_launch_time=1
    slow_query_log_file=/opt/mariadb/log/mariadb-slow.log
    
    #Optimization
    group_concat_max_len=204800
    max_connections=500
    max_connect_errors=1000
    max_allowed_packet=1024M
    innodb_buffer_pool_size=1024M
    eof
    
    cat <<eof|tee /etc/my.cnf.d/client.cnf
    [client]
    socket=/opt/mariadb/data/mysql.socket
    eof
    

    初始化目录

    mkdir /opt/mariadb/data
    mkdir /opt/mariadb/log
    

    设置权限

    setenforce 0
    sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
    groupadd mysql
    useradd mysql -r -g mysql -s /bin/false
    chown -R mysql:mysql /opt/mariadb
    

    设置环境变量

    echo 'export PATH=$PATH:/opt/mariadb/bin' > /etc/profile.d/mariadb.sh
    source /etc/profile
    

    初始化数据库

    /opt/mariadb/scripts/mariadb-install-db
    

    设置服务

    cp /opt/mariadb/support-files/systemd/mariadb.service /etc/systemd/system
    sed -i \
    -e "s|/usr/local/mysql|/opt/mariadb|g" \
    -e "/WantedBy=multi-user.target/a Alias=mysql.service" \
    /etc/systemd/system/mariadb.service
    sed -i "s|/usr/local/mysql|/opt/mariadb|g" /opt/mariadb/bin/galera_recovery
    

    启动服务

    systemctl enable mariadb --now
    systemctl status mariadb
    

    登录

    mysql -uroot -p
    

    如果报错mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

    yum install libncurses* -y

    设置密码

    alter user "root"@"localhost" identified by "YOUR_PASSWORD";
    flush privileges;
    

    相关文章

      网友评论

          本文标题:CentOS 8 MariaDB 10.6.14 二进制安装

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