因为业务系统性能问题,所以决定将数据库更换为MariaDB尝试一下,先配置了一台作为测试,本以为在CentOS7下用yum安装MariaDB应该和MySQL一样简单。
一、添加yum源
找到官网 https://downloads.mariadb.org/mariadb/repositories/ 按照官方指导添加yum源
# MariaDB 10.4 CentOS repository list - created 2019-10-04 02:50 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
或者用国内镜像
# MariaDB 10.4 CentOS repository list - created 2019-10-04 02:50 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.4/centos7-amd64
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
然后运行 yum install MariaDB-server MariaDB-client 。
嗯,OK,等待安装完毕。然后运行和启用自动运行:
systemctl start mariadb
systemctl enable mariadb
运行数据库初始化配置,这里按提示就ok
mysql_secure_installation
配置完毕,添加防火墙
firewall-cmd --add-port 3306/tcp --permanent
firewall-cmd --reload
完毕,连接,成功!大功告成!
然而。。。。按照mysql的尿性,默认字符集应该是latin,需要改utf8,(简单:改改配置文件就ok)。so,
第二步,配置文件
2.1步是寻找配置文件,其实在写下这段文字时我依旧不相信这是真的配置文件,我也不知道为什么我的配置文件这么空荡荡的,以下便是我第一次打开配置文件时的内容:
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
然后。。。。。就没有然后了
自己写吧
[mysqld]
datadir=/data/mariadb_data
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
然后保存
反正怎么都可以启动的