运维-MariaDB 数据库安装

MariaDB是MySQL关系数据库管理系统的一个复刻,由社区开发,有商业支持,旨在继续保持在GNU GPL下开源。

安装 & 配置

  1. 添加源
    访问 https://downloads.mariadb.org/mariadb/repositories 找到合适的源

  2. 添加源
    vim /etc/yum.repos.d/MariaDB.repo

1
2
3
4
5
6
7
# MariaDB 10.3 CentOS repository list - created 2019-04-09 06:51 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
  1. yum 安装

    1
    2
    yum makecache
    yum install mariadb-server mariadb
  2. 设置开机启动

    1
    2
    systemctl start mariadb
    systemctl enable mariadb
  3. 初始化数据库

    1
    mysql_secure_installation
  4. 添加数据库

    1
    2
    3
    4
    5
    6
    mysql -hlocalhost -uroot -p
    CREATE DATABASE `blog` DEFAULT CHARACTER SET = `utf8mb4` DEFAULT COLLATE = `utf8mb4_unicode_ci`;
    CREATE USER 'blog'@'localhost' IDENTIFIED BY 'blog';
    GRANT ALL PRIVILEGES ON blog.* TO 'blog'@'localhost';
    SHOW GRANTS FOR 'blog'@'localhost';
    FLUSH PRIVILEGES;
您的支持将鼓励我继续创作