欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Centos7下编译安装mariadb 博客分类: Linux Centos7MariaDB 

程序员文章站 2024-03-17 00:02:34
...
https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.3.10/source/mariadb-10.3.10.tar.gz
https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.2.18/source/mariadb-10.2.18.tar.gz
https://mariadb.com/kb/en/library/installing-mariadb-binary-tarballs/ 二进制Tarballs包安装说明(官网)
实操:
# yum -y install ncurses-devel openssl-devel libevent-devel jemallloc-devel cmake
# yum -y install gcc gcc++ gcc-c++
# yum -y install bison
# groupadd -r mysql == -r 创建一个系统组。
# useradd -g mysql -s /sbin/nologin mysql
# mkdir /usr/local/mysql
# mkdir -pv /data/mysql == -v print a message for each created directory
# chown -R mysql:mysql /data/mysql/
# cd /usr/local/src
# wget https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.2.18/source/mariadb-10.2.18.tar.gz
# tar -zxvf mariadb-10.2.18.tar.gz
# cd mariadb-10.2.18
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITHOUT_TOKUDB=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STPRAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWIYH_READLINE=1 -DWIYH_SSL=system -DVITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

# make clean  清理此前的编译所生成的文件
# rm -rf CMakeCache.txt

# make && make install
后续设置
# cd /usr/local/mysql/
# chown –R mysql:mysql . 
# scripts/mysql_install_db –datadir=/data/mysql –user=mysql    ==安装系统数据库
# chown –R root . 
# cp support-files/my-huge.cnf /etc/my.cnf
# vim /etc/my.cnf
  在[mysqld]部分增加 datadir=/data/mysql/
# vim /etc/profile   ==把mariadb库文件链接到默认位置
  export PATH=$PATH:/usr/local/mysql/bin
# ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
# ln -s /usr/local/mysql/include/mysql /usr/include/mysql
# vim /etc/systemd/system/mariadb.service
[Unit]
        Description=MariaDB server and services
        After=syslog.target
        After=network.target
        [Service]
        Type=simple
        User=mysql
        Group=mysql
        ExecStart=/usr/local/mysql/bin/mysqld_safe --basedir=/usr/local/mysql
        TimeoutSec=300
        PrivateTmp=false
        [Install]
        WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl start mariadb
# systemctl enable mariadb
# export PATH=$PATH:/usr/local/mysql/bin  ==不重启系统直接使用新PATH
# mysql_secure_installation ==初始化数据库运行环境
相关标签: Centos7 MariaDB