阿里云服务器下源码编译安装mariadb-10.5.1数据库

MariaDB官方发布最新的数据库安装包
环境:centos7
准备:mariadb-10.5.1.tar.gz 数据安装包
第一步: 创建mysql用户

useradd -r -s /sbin/nologin -d /data/mysql mysql
 ` ``
第二步:安装编译时需要用到的包

yum install bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel -y


安装依赖包的时候可以用阿里云的epel源使用脚本进行配置

```bash
#!/bin/bash
# chkconfig: 2345 99 99
cd /etc/yum.repos.d/
ls | egrep -vi "base|app" |xargs rm -rf
sed -i 's/^mirrorlist/#&/' *
sed -i 's/^#baseurl/baseurl/' *
sed -i 's#http://http://mirrors.ucloud.cn#https://mirrors.aliyun.com#' *
yum clean all && yum repolist
yum install -y wget
wget https://mirrors.aliyun.com/centos/7.7.1908/extras/x86_64/Packages/epel-release-7-11.noarch.rpm -P /tmp/
yum install -y /tmp/epel-release-7-11.noarch.rpm
rm -rf epel-testing.repo
sed -i 's/^metalink/#&/' /etc/yum.repos.d/epel.repo
sed -i 's/^#baseurl/baseurl/' /etc/yum.repos.d/epel.repo
sed -i 's#http://download.fedoraproject.org/pub/epel/7/$basearch#https://mirrors.aliyun.com/epel/7/x86_64/#' /etc/yum.repos.d/epel.repo
yum clean all && yum repolist

第二步:创建家目录

[root@centos7-4 ~]# mkdir -p /data/mysql
[root@centos7-4 ~]# chown mysql:mysql /data/mysql/
[root@centos7-4 ~]# ll -d /data/mysql/ ###修改家目录所有者、所属组
drwxr-xr-x 2 mariadb mariadb 6 Sep 28 20:26 /data/mysql/

第三步:解压缩
[root@centos7-4 ~]# tar xvf mariadb-10.5.1.tar.gz
[root@centos7-4 ~]# cd mariadb-10.5.1/

cmake . \
-DCMAKE_INSTALL_PREFIX=/app/mysql \
-DMYSQL_DATADIR=/data/mysql/ \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITHOUT_MROONGA_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_ZLIB=system \
-DWITH_LIBWRAP=0 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_UNIX_ADDR=/app/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make -j 4 && make install

提示:如果出错,执行rm -f CMakeCache.txt
第四步:生成数据库文件

[root@centos7-4 support-files]# cd /app/mysql/
[root@centos7-4 mysql]# scripts/mysql_install_db --datadir=/data/mysql --user=mysql

第五步:拷贝配置文件

[root@centos7-4 mysql]# cd  /app/mysql/support-files 
[root@centos7-4 support-files]# cp my-huge.cnf /etc/my.cnf
[root@centos7-4 support-files]# vim /etc/my.cnf
[client]
socket          = /data/mysql/mysql.sock
 
[mysqld]
datadir=/data/mysql
port            = 3306
socket          = /data/mysql/mysql.sock

第六步:拷贝启动文件

[root@centos7-4 mysql]# cd  /app/mysql/support-files 
[root@centos7-4 support-files]# cp mysql.server /etc/init.d/mysqld

第七步:添加启动列表

chkconfig --add mysql

第八步:修改配置文件中的socker权限目录

[root@centos7-4 support-files]# vim /etc/my.cnf
[client]
socket          = /data/mysql/mysql.sock
 
[mysqld]
datadir=/data/mysql
port            = 3306
socket          = /data/mysql/mysql.sock

第九步:启动服务

[root@centos7-4 support-files]# service mysqld start

第十步:

[root@centos7-4 support-files]# echo PATH=/app/mysql/bin:$PATH > /etc/profiled.d/mysql.sh
[root@centos7-4 support-files]# . /etc/profile.d/mysql.sh

终于完成

发布了15 篇原创文章 · 获赞 33 · 访问量 1950

猜你喜欢

转载自blog.csdn.net/sadcd/article/details/104482775