添加MariaDB软件仓库

1
2
3
4
5
6
7
8
$ vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name=MariaDB
baseurl=http://yum.mariadb.org/10.0/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
priority=1
$ yum check-update

添加XtraBackup软件仓库

1
2
3
4
5
6
7
8
$ vi /etc/yum.repos.d/MariaDB.repo
[percona]
name=CentOS $releasever - Percona
baseurl=http://repo.percona.com/centos/$releasever/os/$basearch/
gpgkey=https://www.percona.com/downloads/RPM-GPG-KEY-percona
gpgcheck=1
priority=2
$ yum check-update

导入MariaDB证书

1
$ rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

导入Percona证书

1
$ rpm --import https://www.percona.com/downloads/RPM-GPG-KEY-percona

安装MariaDB

1
$ yum install MariaDB-server MariaDB-client

安装Percona Xtrabackup

1
$ yum install percona-xtrabackup

启动MariaDB

1
$ /etc/init.d/mysql start

开机自动启动MariaDB

1
$ chkconfig mysql on
  • 或者
1
$ systemctl enable mariadb.service

初始化安全设置

1
$ /usr/bin/mysql_secure_installation

允许root远程登录

1
2
3
$ mysql -uroot -p123456
MariaDB[] > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
MariaDB[] > FLUSH PRIVILEGES;