• CentOS 7 安装 MariaDB


    CentOS 7 安装 MariaDB

    首先配置阿里源

    https://www.cnblogs.com/weige007/p/12099141.html

    1. 阿里云源下载安装 MariaDB

    yum install mariadb-server mariadb -y

    2. 使用 systemctl 管理 MariaDB 服务

    systemctl start mariadb      # 启动MariaDB  
    systemctl stop mariadb       # 停止MariaDB 
    systemctl restart mariadb    # 重启MariaDB            
    systemctl enable mariadb     # 设置开机启动

    3. 初始化 MariaDB

    mysql_secure_installation

    4. 中文编码设置,编辑 /etc/my.cnf 文件,添加以下内

    [mysqld]
    character-set-server=utf8
    collation-server=utf8_general_ci
    log-error=/var/log/mysqld.log
    [client]
    default-character-set=utf8
    [mysql]
    default-character-set=utf8

    5. 配置完之后重启服务

    systemctl restart mariadb

    6. 进入MariaDB 数据库

    [root@localhost ~]# mysql -uroot -p
    Enter password:

    7. 创建数据库用户

    MariaDB [(none)]> create user rpw@'127.0.0.1' identified by 'admin';
    Query OK, 0 rows affected (0.04 sec)
    
    MariaDB [(none)]> use mysql
    Database changed
    MariaDB [mysql]> select host,user,password from user;
    +-----------------------+-------+-------------------------------------------+
    | host                  | user  | password                                  |
    +-----------------------+-------+-------------------------------------------+
    | localhost             | root  | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
    | localhost.localdomain | root  | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
    | 127.0.0.1             | root  | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
    | ::1                   | root  | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
    | 127.0.0.1             | rpw   | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
    +-----------------------+-------+-------------------------------------------+
    5 rows in set (0.00 sec)
    
    MariaDB [mysql]> 

    8. 数据库权限设置

    MariaDB [(none)]> use mysql;
    Database changed
    MariaDB [mysql]> grant all privileges on *.* to rpw@127.0.0.1;
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [mysql]> show grants for rpw@127.0.0.1;
    +---------------------------------------------------------------------------------------------------------------------+
    | Grants for rpw@127.0.0.1                                                                                            |
    +---------------------------------------------------------------------------------------------------------------------+
    | GRANT ALL PRIVILEGES ON *.* TO 'rpw'@'127.0.0.1' IDENTIFIED BY PASSWORD '*4ACFE3202A5FF5CF467898FC58AAB1D615029441' |
    +---------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    MariaDB [mysql]> 

    # 刷新权限

     MariaDB [mysql]> flush privileges;
     Query OK, 0 rows affected (0.00 sec)

    9. 移除权限

    MariaDB [mysql]> revoke all privileges on *.* from rpw@127.0.0.1;
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [mysql]> 

       

    风吹散的仅仅是回忆
  • 相关阅读:
    JVM系列六(自定义插入式注解器).
    JVM系列五(Javac 字节码编译器).
    2019 — 求不得,放不下
    Mybatis 条件判断单双引号解析问题
    JVM系列四(对象分配策略).
    JVM系列三(垃圾收集器).
    Spring MVC -- Spring Tool Suite和Maven(安装Tomcat、JDK)
    Spring MVC -- 单元测试和集成测试
    Spring MVC -- 下载文件
    Spring MVC -- 上传文件
  • 原文地址:https://www.cnblogs.com/weige007/p/12103586.html
Copyright © 2020-2023  润新知