1. 添加mariadb源
cat <<EOF > /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.4/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck=1
EOF
2. 更新缓存
yum clean all
yum makecache
yum repolist
3.显示可安装的版本
#这个可以看版本号
yum search mariadb --showduplicates
或
yum search mariadb
4. 安装
yum -y install MariaDB-server MariaDB-client
5. 修改数据存储路径
mkdir -p /data/mysql
cp -r /var/lib/mysql/* /data/mysql/
chown -R mysql:mysql /data/mysql
vim /etc/my.cnf
[client]
socket = /data/mysql/mysql.sock
[mysqld]
datadir = /data/mysql
socket = /data/mysql/mysql.sock
6. 启动
systemctl enable mariadb --now
7. 设置密码
mysql_secure_installation
8. 设置开机启动
systemctl enable mariadb
9. 启动 mariadb
systemctl start mariadb
10. 安装错误时的卸载操作
rpm -aq|grep Maria*
yum -y remove Maria*