CentOS 7 安装 MariaDB 10.1

来源:互联网 发布:气步枪瞄准器 知乎 编辑:程序博客网 时间:2024/05/21 08:50

CentOS 7 安装 MariaDB 10.1

使用默认的 yum install mariadb-server时,默认安装的是和Mysql相兼容的5.5版本。想安装Mariadb 10.1或以上版本,必须先指定yum源。


  1. 使用源配置向导

    https://downloads.mariadb.org/mariadb/repositories

    可以选择合适的操作系统和想要安装的MariaDB版本,然后自动生成源配置。

  2. 我使用的是:

     # MariaDB 10.1 CentOS repository list - created 2016-05-12 09:28 UTC # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
  3. 配置yum源

    /etc/yum.repos.d/
    touch MariaDB.repo
    vim MariaDB.repo

    将上面的内容复制进去,保存退出。

  4. 安装MariaDB 10.1

    yum install MariaDB-server MariaDB-client

    如果出现了 MariaDB can’t be installed because of conflict with mariadb-libs-xxxx,则需要先卸载当前安装的版本:

    yum remove mariadb-libs*

    安装完成后,会提示你为root设置密码,此时需要先运行Mariadb。

  5. 运行 MariaDB

    service mysql start

    输出:

    Starting mysql (via systemctl): [ OK ]

  6. 配置 MariaDB

    mysql_secure_installation

    如果出现 error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory")',则说明mariadb没有启动,需要先运行Mariadb,参考第5步。

     Enter current password for root (enter for none):  输入当前的root密码(默认空),直接回车 Set root password? [Y/n] 设置新密码,y Remove anonymous users? [Y/n] 移除匿名用户,y Disallow root login remotely? [Y/n] 禁止root用户远程登录,y Remove test database and access to it? [Y/n] 移除测试数据库,y Reload privilege tables now? [Y/n] y
  7. 配置
    Mysql在Linux上默认是表名大小写敏感的,需要手动配置才能使之忽略大小写:

    vim vim /etc/my.cnf

    [mysqld]下,修改(没有则添加):

    lower_case_table_names=1

    然后重启mysql服务

    service mysql restart

  1. 大功告成!
原创粉丝点击