美文网首页
Centos7安装MariaDB

Centos7安装MariaDB

作者: LI木水 | 来源:发表于2018-09-29 14:53 被阅读0次

    什么是MariaDB

    mariadb1.png

    MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

    MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。


    一、传统方式安装

    首先去官网https://downloads.mariadb.org/mariadb/repositories/#mirror=shanghai-university安装提示选择对应的系统和mariadb版本,下面会显示对应的操作方法。

    mariadb.png

    1.编辑repo文件vim /etc/yum.repos.d/MariaDB.repo

    # MariaDB 10.3 CentOS repository list - created 2018-09-29 06:16 UTC 
    # [http://downloads.mariadb.org/mariadb/repositories/]
    [mariadb]
    name = MariaDB
    baseurl = [http://yum.mariadb.org/10.3/centos7-amd64](http://yum.mariadb.org/10.3/centos7-amd64)
    gpgkey=[https://yum.mariadb.org/RPM-GPG-KEY-MariaDB](https://yum.mariadb.org/RPM-GPG-KEY-MariaDB)
    gpgcheck=1
    

    如果卡请使用国内源

    [mariadb]
    name = MariaDB
    baseurl = http://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/
    gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    

    2.安装

    sudo yum install MariaDB-server MariaDB-client
    

    安装完成会提示你设置root密码

    PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
    To do so, start the server, then issue the following commands:
    
    '/usr/bin/mysqladmin' -u root password 'new-password'
    '/usr/bin/mysqladmin' -u root -h Ieat3 password 'new-password'
    
    Alternatively you can run:
    '/usr/bin/mysql_secure_installation'
    

    3.设置root密码
    先启动数据库

    [root@Ieat3 ~]# service mariadb start
    

    设置密码

    [root@Ieat3 ~]# mysqladmin -u root password '123456'
    

    测试

    [root@Ieat3 ~]# mysql -uroot -p123456
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 9
    Server version: 10.3.9-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    MariaDB [(none)]> 
    
    

    二、docker安装

    非常简单

    docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=123456 -d mariadb:tag
    

    更多docker安装配置参考:https://hub.docker.com/_/mariadb/

    相关文章

      网友评论

          本文标题:Centos7安装MariaDB

          本文链接:https://www.haomeiwen.com/subject/wxavoftx.html