zoukankan      html  css  js  c++  java
  • 数据库

    21、部署 MariaDB 数据库

    server0 上部署 MariaDB。要求如下: 仅允许从 server0 系统上使用登陆到数据库。

    登陆数据库所用的账号为 root,密码为 root_password。

     http://content.example.com/courses/rhce/rhel7.0/materials/mariadb/mariadb.dump  下载文件,并将其恢复为 legacy 库。

    并设置数据库访问:

    用户名

    密码

    权限

    Mary

    xxx

    对 legacy 库的所有数据有选择操作权限

    Legacy

    xxx

    对 legacy 库的所有数据有选择、插入、更新、删除操作权

    Report

    xxx

    对 legacy 库的所有数据有选择操作权限

    解题:

     

    [root@server0 ~]# yum -y install mariadb mariadb-server [root@server0 ~]# systemctl enable mariadb

    ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

    [root@server0 ~]# systemctl restart mariadb

    [root@server0 ~]# systemctl enable mariadb

    [root@server0 ~]# systemctl enable mariadb

    [root@server0 ~]# mysql_secure_installation --初始化 mariadb

    Set root password? [Y/n]y --设置数据库的 root 用户密码 Disallow root login remotely? [Y/n]y --禁止 root 用户远程连接

    [root@server0 ~]# wget http://content.example.com/courses/rhce/rhel7.0/materials/mariadb/mariadb.dump [root@server0 ~]# mysql -proot_password --使用‘root_password’这个密码来连接 mysql

    MariaDB [(none)]> create database legacy;

    MariaDB [(none)]> use legacy; Database changed

    MariaDB [legacy]> source /root/mariadb.dump --恢复数据库文件

    MariaDB [legacy]> show tables;

    MariaDB [(none)]> grant select on legacy.* to 'mary'@'localhost' identified by 'mary_password';--添加授权用户并设置密码

    MariaDB [(none)]> grant update,delete,insert,select on legacy.* to 'legacy'@'localhost' identified by 'legacy_password';

    MariaDB [(none)]> grant select on legacy.* to 'report'@'localhost' identified by 'report_password';

    MariaDB [(none)]> flush privileges; --刷新权限表

    22、数据查询填空

     server0 上登陆数据库,查看 legacy 库进行查询,并将结果填入相应的框格中。 Q1  product 表中,查询 RT-AC68U 的产品 id()

    Q2 查询类别为 Servers 的产品的数量()

    模拟考环境请在 http://classroom.example.com/cgi-bin/mariadb 提交

    解题:

     

    MariaDB [legacy]> select id,name from product where name='RT-AC68U';

    MariaDB [legacy]> select count(product.id) from product,category where category.name='Servers' and category.id=product.id_category;

  • 相关阅读:
    Python开发【第二十一篇】:Web框架之Django【基础】
    梳理
    Python Day15 jQuery
    day12 html基础
    Python day11 Mysql
    锻炼马甲线
    第一章:软件性能测试基本概念
    第4关—input()函数
    第3关—条件判断与嵌套
    第2关—数据类型与转换
  • 原文地址:https://www.cnblogs.com/xnb123/p/8024694.html
Copyright © 2011-2022 走看看