Bo's Oracle Station

查看: 2101|回复: 0

课程第35/36次

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2019-7-7 10:03:24 | 显示全部楼层 |阅读模式
端口转发:/etc/rc.local:
  1. iptables -t nat -A PREROUTING -s 192.168.0.0/24 -d 192.168.0.103 -p tcp  --dport 5423 -j DNAT --to-destination 192.168.0.103:80
复制代码
或者可选可以装一下:
yum -y install iptables-services
service iptables save

拷贝/usr/share/doc/httpd=2.4.26/httpd-vhost.conf到/etc/httpd/conf.d/vhosts.conf:
  1. <VirtualHost *:80>
  2.     ServerAdmin webmaster@www3.example.com
  3.     DocumentRoot "/var/www/html/www3"
  4.     ServerName www3.example.com
  5.     ErrorLog "/var/log/httpd/www3-error_log"
  6.     CustomLog "/var/log/httpd/www3-access_log" common
  7. </VirtualHost>

  8. <VirtualHost *:80>
  9.     ServerAdmin webmaster@server3.example.com
  10.     DocumentRoot "/var/www/html/server3"
  11.     ServerName server3.example.com
  12.     ErrorLog "/var/log/httpd/server3-error_log"
  13.     CustomLog "/var/log/httpd/server3-access_log" common
  14. </VirtualHost>

复制代码
mod_ssl的配置:
  1. <VirtualHost *:80>
  2.     ServerAdmin webmaster@www3.example.com
  3.     DocumentRoot "/var/www/html/www3"
  4.     ServerName www3.example.com
  5.     ErrorLog "/var/log/httpd/www3-error_log"
  6.     CustomLog "/var/log/httpd/www3-access_log" common
  7. </VirtualHost>

  8. <VirtualHost *:80>
  9.     ServerAdmin webmaster@server3.example.com
  10.     DocumentRoot "/var/www/html/server3"
  11.     ServerName server3.example.com
  12.     ErrorLog "/var/log/httpd/server3-error_log"
  13.     CustomLog "/var/log/httpd/server3-access_log" common
  14. </VirtualHost>


  15. <VirtualHost *:443>
  16.     SSLEngine on
  17.     SSLCACertificateFile /var/www/html/www3/example-ca.crt
  18.     SSLCertificateFile  /var/www/html/www3/server3.crt
  19.     SSLCertificateKeyFile  /var/www/html/www3/server3.key
  20.     ServerAdmin webmaster@www3.example.com
  21.     DocumentRoot "/var/www/html/www3"
  22.     ServerName www3.example.com
  23.     ErrorLog "/var/log/httpd/www3-error_log"
  24.     CustomLog "/var/log/httpd/www3-access_log" common
  25. </VirtualHost>
复制代码
  1. [root@server3 ~]# firewall-cmd  --permanent --add-rich-rule='rule family=ipv4 source address=192.168.1.0/24 service name="http" log level=notice reject'
  2. success
  3. [root@server3 ~]# firewall-cmd  --permanent --add-rich-rule='rule family=ipv4 source address=192.168.0.0/24 service name="http" log level=notice accept'
复制代码
对应iptables
:Chain IN_public_log (1 references)
target     prot opt source               destination
LOG        tcp  --  192.168.1.0/24       0.0.0.0/0            tcp dpt:80 ctstate                                                                              NEW LOG flags 0 level 5
LOG        tcp  --  192.168.0.0/24       0.0.0.0/0            tcp dpt:80 ctstate                                                                              NEW LOG flags 0 level 5

2019-07-14:---------------------------------------------------------------------------
  1. [root@server3 etc]# mysql -u root --password=redhat
  2. Welcome to the MariaDB monitor.  Commands end with ; or \g.
  3. Your MariaDB connection id is 2
  4. Server version: 5.5.60-MariaDB MariaDB Server

  5. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

  6. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  7. MariaDB [(none)]>
复制代码

不输入密码是不行的:
  1. MariaDB [(none)]> exit
  2. Bye
  3. [root@server3 etc]# mysql -u root
  4. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
  5. [root@server3 etc]#
复制代码

-----------------------
  1. [root@server3 etc]# mysql -u root --password=redhat
  2. Welcome to the MariaDB monitor.  Commands end with ; or \g.
  3. Your MariaDB connection id is 5
  4. Server version: 5.5.60-MariaDB MariaDB Server

  5. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

  6. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  7. MariaDB [(none)]> show databases;
  8. +--------------------+
  9. | Database           |
  10. +--------------------+
  11. | information_schema |
  12. | mysql              |
  13. | performance_schema |
  14. +--------------------+
  15. 3 rows in set (0.01 sec)

  16. MariaDB [(none)]> use mysql;
  17. Reading table information for completion of table and column names
  18. You can turn off this feature to get a quicker startup with -A

  19. Database changed
  20. MariaDB [mysql]> show tables
  21.     -> ;
  22. +---------------------------+
  23. | Tables_in_mysql           |
  24. +---------------------------+
  25. | columns_priv              |
  26. | db                        |
  27. | event                     |
  28. | func                      |
  29. | general_log               |
  30. | help_category             |
  31. | help_keyword              |
  32. | help_relation             |
  33. | help_topic                |
  34. | host                      |
  35. | ndb_binlog_index          |
  36. | plugin                    |
  37. | proc                      |
  38. | procs_priv                |
  39. | proxies_priv              |
  40. | servers                   |
  41. | slow_log                  |
  42. | tables_priv               |
  43. | time_zone                 |
  44. | time_zone_leap_second     |
  45. | time_zone_name            |
  46. | time_zone_transition      |
  47. | time_zone_transition_type |
  48. | user                      |
  49. +---------------------------+
  50. 24 rows in set (0.00 sec)

  51. MariaDB [mysql]>
复制代码
  1. [root@server3 etc]# mysql -u root  -h localhost  --password=redhat
  2. Welcome to the MariaDB monitor.  Commands end with ; or \g.
  3. Your MariaDB connection id is 3
  4. Server version: 5.5.60-MariaDB MariaDB Server

  5. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

  6. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  7. MariaDB [(none)]> show databases;
  8. +--------------------+
  9. | Database           |
  10. +--------------------+
  11. | information_schema |
  12. | mysql              |
  13. | performance_schema |
  14. +--------------------+
  15. 3 rows in set (0.00 sec)

  16. MariaDB [(none)]> create database inventory;
  17. Query OK, 1 row affected (0.00 sec)

  18. MariaDB [(none)]> use inventory ;
  19. Database changed
  20. MariaDB [inventory]> show tables;
  21. Empty set (0.00 sec)

  22. MariaDB [inventory]> create table product (id int(11) ,
  23.     ->   name varchar(100),
  24.     -> price double,
  25.     -> stock int(11),
  26.     -> id_category int(11),
  27.     -> id_manufacturer int(11)  ) ;
  28. Query OK, 0 rows affected (0.02 sec)

  29. MariaDB [inventory]> show tables;
  30. +---------------------+
  31. | Tables_in_inventory |
  32. +---------------------+
  33. | product             |
  34. +---------------------+
  35. 1 row in set (0.00 sec)

  36. MariaDB [inventory]> desc  product;
  37. +-----------------+--------------+------+-----+---------+-------+
  38. | Field           | Type         | Null | Key | Default | Extra |
  39. +-----------------+--------------+------+-----+---------+-------+
  40. | id              | int(11)      | YES  |     | NULL    |       |
  41. | name            | varchar(100) | YES  |     | NULL    |       |
  42. | price           | double       | YES  |     | NULL    |       |
  43. | stock           | int(11)      | YES  |     | NULL    |       |
  44. | id_category     | int(11)      | YES  |     | NULL    |       |
  45. | id_manufacturer | int(11)      | YES  |     | NULL    |       |
  46. +-----------------+--------------+------+-----+---------+-------+
  47. 6 rows in set (0.01 sec)

  48. MariaDB [inventory]>
复制代码
  1. MariaDB [inventory]> select  * from product;
  2. Empty set (0.00 sec)

  3. MariaDB [inventory]> alter table product add constraint con1 primary key (id) ;
  4. Query OK, 0 rows affected (0.02 sec)
  5. Records: 0  Duplicates: 0  Warnings: 0

  6. MariaDB [inventory]> desc product;
  7. +-----------------+--------------+------+-----+---------+-------+
  8. | Field           | Type         | Null | Key | Default | Extra |
  9. +-----------------+--------------+------+-----+---------+-------+
  10. | id              | int(11)      | NO   | PRI | 0       |       |
  11. | name            | varchar(100) | YES  |     | NULL    |       |
  12. | price           | double       | YES  |     | NULL    |       |
  13. | stock           | int(11)      | YES  |     | NULL    |       |
  14. | id_category     | int(11)      | YES  |     | NULL    |       |
  15. | id_manufacturer | int(11)      | YES  |     | NULL    |       |
  16. +-----------------+--------------+------+-----+---------+-------+
  17. 6 rows in set (0.00 sec)

  18. MariaDB [inventory]>
复制代码
  1. MariaDB [inventory]> insert into product values (1 ,'SDSSDP-128G-G25 2.5',82.04,                                                                             30, 3,1 ) ;
  2. Query OK, 1 row affected (0.00 sec)

  3. MariaDB [inventory]> select  * from product;
  4. +----+---------------------+-------+-------+-------------+-----------------+
  5. | id | name                | price | stock | id_category | id_manufacturer |
  6. +----+---------------------+-------+-------+-------------+-----------------+
  7. |  1 | SDSSDP-128G-G25 2.5 | 82.04 |    30 |           3 |               1 |
  8. +----+---------------------+-------+-------+-------------+-----------------+
  9. 1 row in set (0.00 sec)

  10. MariaDB [inventory]>
复制代码
  1. MariaDB [inventory]> select  * from product where name like '%G%';
  2. +----+---------------------+-------+-------+-------------+-----------------+
  3. | id | name                | price | stock | id_category | id_manufacturer |
  4. +----+---------------------+-------+-------+-------------+-----------------+
  5. |  1 | SDSSDP-128G-G25 2.5 |  89.9 |    60 |           3 |               1 |
  6. +----+---------------------+-------+-------+-------------+-----------------+
  7. 1 row in set (0.00 sec)

  8. MariaDB [inventory]>  select  * from product where name like '%F%';
  9. Empty set (0.00 sec)

  10. MariaDB [inventory]>  select  * from product where name like 'S_S%';
  11. +----+---------------------+-------+-------+-------------+-----------------+
  12. | id | name                | price | stock | id_category | id_manufacturer |
  13. +----+---------------------+-------+-------+-------------+-----------------+
  14. |  1 | SDSSDP-128G-G25 2.5 |  89.9 |    60 |           3 |               1 |
  15. +----+---------------------+-------+-------+-------------+-----------------+
  16. 1 row in set (0.00 sec)

  17. MariaDB [inventory]>  select  * from product where name like 'S__S%';
  18. +----+---------------------+-------+-------+-------------+-----------------+
  19. | id | name                | price | stock | id_category | id_manufacturer |
  20. +----+---------------------+-------+-------+-------------+-----------------+
  21. |  1 | SDSSDP-128G-G25 2.5 |  89.9 |    60 |           3 |               1 |
  22. +----+---------------------+-------+-------+-------------+-----------------+
  23. 1 row in set (0.00 sec)

  24. MariaDB [inventory]>  select  * from product where name like 'S___S%';
  25. Empty set (0.00 sec)

  26. MariaDB [inventory]>
复制代码
  1. MariaDB [inventory]>  select  * from product where name like 'S___S%';
  2. Empty set (0.00 sec)

  3. MariaDB [inventory]> select  * from product where id_category in ( 1, 2 ) ;
  4. Empty set (0.00 sec)

  5. MariaDB [inventory]> select  * from product where id_category in ( 1, 2, 3);
  6. +----+---------------------+-------+-------+-------------+-----------------+
  7. | id | name                | price | stock | id_category | id_manufacturer |
  8. +----+---------------------+-------+-------+-------------+-----------------+
  9. |  1 | SDSSDP-128G-G25 2.5 |  89.9 |    60 |           3 |               1 |
  10. +----+---------------------+-------+-------+-------------+-----------------+
  11. 1 row in set (0.00 sec)
复制代码
SQL 分为: DQL(select)   DDL ( alter   create  truncate  drop)   DML (insert  delete  update) TCL (commit  rollback) DCL(grant  revoke)
对于DDL类型的权限,在grant、revoke时要用户退出才能生效。

逻辑备份mariadb:
  1. [root@server3 etc]# mysqldump -u root -p inventory > /root/inventory.mdb
  2. Enter password:
  3. [root@server3 etc]# cd
  4. [root@server3 ~]# vim inventory.mdb
  5. [root@server3 ~]#
复制代码

---------------------------------------------------
  1. MariaDB [inventory]> show tables;
  2. +---------------------+
  3. | Tables_in_inventory |
  4. +---------------------+
  5. | product             |
  6. +---------------------+
  7. 1 row in set (0.00 sec)

  8. MariaDB [inventory]> select  * from product;
  9. +----+---------------------+-------+-------+-------------+-----------------+
  10. | id | name                | price | stock | id_category | id_manufacturer |
  11. +----+---------------------+-------+-------+-------------+-----------------+
  12. | 10 | SDSSDP-128G-G25 2.5 |  89.9 |    60 |           3 |               1 |
  13. +----+---------------------+-------+-------+-------------+-----------------+
  14. 1 row in set (0.00 sec)

  15. MariaDB [inventory]> drop table product;
  16. Query OK, 0 rows affected (0.01 sec)

  17. MariaDB [inventory]> show tables;
  18. Empty set (0.00 sec)

  19. MariaDB [inventory]> source /root/inventory2.mdb
  20. Query OK, 0 rows affected (0.01 sec)

  21. Query OK, 0 rows affected (0.00 sec)

  22. Query OK, 0 rows affected (0.00 sec)

  23. Query OK, 0 rows affected (0.00 sec)

  24. Query OK, 0 rows affected (0.00 sec)

  25. Query OK, 0 rows affected (0.00 sec)

  26. Query OK, 0 rows affected (0.00 sec)

  27. Query OK, 0 rows affected (0.00 sec)

  28. Query OK, 0 rows affected (0.00 sec)

  29. Query OK, 0 rows affected (0.00 sec)

  30. Query OK, 0 rows affected (0.00 sec)

  31. Query OK, 0 rows affected (0.00 sec)

  32. Query OK, 0 rows affected (0.00 sec)

  33. Query OK, 0 rows affected (0.01 sec)

  34. Query OK, 0 rows affected (0.00 sec)

  35. Query OK, 0 rows affected (0.00 sec)

  36. Query OK, 0 rows affected (0.00 sec)

  37. Query OK, 1 row affected (0.00 sec)

  38. Query OK, 0 rows affected (0.00 sec)

  39. Query OK, 0 rows affected (0.00 sec)

  40. Query OK, 0 rows affected (0.00 sec)

  41. Query OK, 0 rows affected (0.00 sec)

  42. Query OK, 0 rows affected (0.00 sec)

  43. Query OK, 0 rows affected (0.00 sec)

  44. Query OK, 0 rows affected (0.00 sec)

  45. Query OK, 0 rows affected (0.00 sec)

  46. Query OK, 0 rows affected (0.00 sec)

  47. Query OK, 0 rows affected (0.00 sec)

  48. MariaDB [inventory]> show tables;
  49. +---------------------+
  50. | Tables_in_inventory |
  51. +---------------------+
  52. | product             |
  53. +---------------------+
  54. 1 row in set (0.00 sec)

  55. MariaDB [inventory]>
复制代码







回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-12-4 01:11 , Processed in 0.040154 second(s), 24 queries .

快速回复 返回顶部 返回列表