目录
1.先确保本机IP地址与网络源可用
ping www.baidu.com //查看你的系统是否能ping通网络
2.下载依赖环境
yum -y install wget bison zlib-devel libcurl-devel boost-devel gcc gcc-c++ cmake ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel make
3.下载mariadb安装包
cd /usr/local/src/
wget -c https://mirrors.aliyun.com/mariadb/mariadb-10.6.7/source/mariadb-10.6.7.tar.gz
如果在本机上下载不了安装包,那就去我的网盘下载安装包,再上传到主机上
链接:https://pan.baidu.com/s/1WS3HC-Ueq-dWyWmMdQz-ww?pwd=4s8a
提取码:4s8a
4.解压安装包
tar -zxvf mariadb-10.6.7.tar.gz
5.配置准备环境
useradd -r -s /sbin/nologin -d /data/mariadb mysql
mkdir -p /data/mariadb
chown -R mysql /data/mariadb/
mkdir /usr/local/mariadb
chown -R mysql.mysql /usr/local/mariadb/
6.生成编译文件
cd /usr/local/src/mariadb-10.6.7/
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DMYSQL_DATADIR=/data/mariadb/ -DSYSCONFDIR=/usr/local/mariadb -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITHOUT_TOKUDB=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
7.预编译
make
8.编译安装
make install
9.配置启动文件
cd /usr/local/mariadb/
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
10.配置my.cnf文件
vim /usr/local/mariadb/my.cnf
编写配置
[mysqld]
basedir=/usr/local/mariadb/
datadir=/data/mariadb/
port=3306
pid-file=/data/mariadb/mysql.pid
socket=/tmp/mysql.sock
[mysqld_safe]
log-error=/data/mariadb/mysql.log
[client]
port=3306
socket=/tmp/mysql.sock
default-character-set=utf8
11.初始化mysql服务
/usr/local/mariadb/scripts/mariadb-install-db --datadir=/data/mariadb
chown -R root /usr/local/mariadb/
chown -R mysql:mysql /data/mariadb/
12.启动mysql服务(3306)
/etc/init.d/mysqld start
ss -antl //查看是否由3306端口
13.将mysql服务添加到开机自启服务中,启动服务
chkconfig --add mysqld
/usr/local/mariadb/bin/mysql
14.初始化mysql服务
/usr/local/mariadb/bin/mysql_secure_installation
15.配置环境变量
echo "export PATH=/usr/local/mariadb/bin:$PATH" > /etc/profile.d/mariadb.sh
. /etc/profile.d/mariadb.sh
16.正常启动mysql服务
mysql -u root -p
本操作是在CentOS8上实现的。