|
端口转发:/etc/rc.local:
- 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:- <VirtualHost *:80>
- ServerAdmin webmaster@www3.example.com
- DocumentRoot "/var/www/html/www3"
- ServerName www3.example.com
- ErrorLog "/var/log/httpd/www3-error_log"
- CustomLog "/var/log/httpd/www3-access_log" common
- </VirtualHost>
- <VirtualHost *:80>
- ServerAdmin webmaster@server3.example.com
- DocumentRoot "/var/www/html/server3"
- ServerName server3.example.com
- ErrorLog "/var/log/httpd/server3-error_log"
- CustomLog "/var/log/httpd/server3-access_log" common
- </VirtualHost>
复制代码 mod_ssl的配置:- <VirtualHost *:80>
- ServerAdmin webmaster@www3.example.com
- DocumentRoot "/var/www/html/www3"
- ServerName www3.example.com
- ErrorLog "/var/log/httpd/www3-error_log"
- CustomLog "/var/log/httpd/www3-access_log" common
- </VirtualHost>
- <VirtualHost *:80>
- ServerAdmin webmaster@server3.example.com
- DocumentRoot "/var/www/html/server3"
- ServerName server3.example.com
- ErrorLog "/var/log/httpd/server3-error_log"
- CustomLog "/var/log/httpd/server3-access_log" common
- </VirtualHost>
- <VirtualHost *:443>
- SSLEngine on
- SSLCACertificateFile /var/www/html/www3/example-ca.crt
- SSLCertificateFile /var/www/html/www3/server3.crt
- SSLCertificateKeyFile /var/www/html/www3/server3.key
- ServerAdmin webmaster@www3.example.com
- DocumentRoot "/var/www/html/www3"
- ServerName www3.example.com
- ErrorLog "/var/log/httpd/www3-error_log"
- CustomLog "/var/log/httpd/www3-access_log" common
- </VirtualHost>
复制代码- [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'
- success
- [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:---------------------------------------------------------------------------
- [root@server3 etc]# mysql -u root --password=redhat
- Welcome to the MariaDB monitor. Commands end with ; or \g.
- Your MariaDB connection id is 2
- Server version: 5.5.60-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)]>
复制代码
不输入密码是不行的:- MariaDB [(none)]> exit
- Bye
- [root@server3 etc]# mysql -u root
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
- [root@server3 etc]#
复制代码
------------------------ [root@server3 etc]# mysql -u root --password=redhat
- Welcome to the MariaDB monitor. Commands end with ; or \g.
- Your MariaDB connection id is 5
- Server version: 5.5.60-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)]> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | mysql |
- | performance_schema |
- +--------------------+
- 3 rows in set (0.01 sec)
- MariaDB [(none)]> use mysql;
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Database changed
- MariaDB [mysql]> show tables
- -> ;
- +---------------------------+
- | Tables_in_mysql |
- +---------------------------+
- | columns_priv |
- | db |
- | event |
- | func |
- | general_log |
- | help_category |
- | help_keyword |
- | help_relation |
- | help_topic |
- | host |
- | ndb_binlog_index |
- | plugin |
- | proc |
- | procs_priv |
- | proxies_priv |
- | servers |
- | slow_log |
- | tables_priv |
- | time_zone |
- | time_zone_leap_second |
- | time_zone_name |
- | time_zone_transition |
- | time_zone_transition_type |
- | user |
- +---------------------------+
- 24 rows in set (0.00 sec)
- MariaDB [mysql]>
复制代码- [root@server3 etc]# mysql -u root -h localhost --password=redhat
- Welcome to the MariaDB monitor. Commands end with ; or \g.
- Your MariaDB connection id is 3
- Server version: 5.5.60-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)]> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | mysql |
- | performance_schema |
- +--------------------+
- 3 rows in set (0.00 sec)
- MariaDB [(none)]> create database inventory;
- Query OK, 1 row affected (0.00 sec)
- MariaDB [(none)]> use inventory ;
- Database changed
- MariaDB [inventory]> show tables;
- Empty set (0.00 sec)
- MariaDB [inventory]> create table product (id int(11) ,
- -> name varchar(100),
- -> price double,
- -> stock int(11),
- -> id_category int(11),
- -> id_manufacturer int(11) ) ;
- Query OK, 0 rows affected (0.02 sec)
- MariaDB [inventory]> show tables;
- +---------------------+
- | Tables_in_inventory |
- +---------------------+
- | product |
- +---------------------+
- 1 row in set (0.00 sec)
- MariaDB [inventory]> desc product;
- +-----------------+--------------+------+-----+---------+-------+
- | Field | Type | Null | Key | Default | Extra |
- +-----------------+--------------+------+-----+---------+-------+
- | id | int(11) | YES | | NULL | |
- | name | varchar(100) | YES | | NULL | |
- | price | double | YES | | NULL | |
- | stock | int(11) | YES | | NULL | |
- | id_category | int(11) | YES | | NULL | |
- | id_manufacturer | int(11) | YES | | NULL | |
- +-----------------+--------------+------+-----+---------+-------+
- 6 rows in set (0.01 sec)
- MariaDB [inventory]>
复制代码- MariaDB [inventory]> select * from product;
- Empty set (0.00 sec)
- MariaDB [inventory]> alter table product add constraint con1 primary key (id) ;
- Query OK, 0 rows affected (0.02 sec)
- Records: 0 Duplicates: 0 Warnings: 0
- MariaDB [inventory]> desc product;
- +-----------------+--------------+------+-----+---------+-------+
- | Field | Type | Null | Key | Default | Extra |
- +-----------------+--------------+------+-----+---------+-------+
- | id | int(11) | NO | PRI | 0 | |
- | name | varchar(100) | YES | | NULL | |
- | price | double | YES | | NULL | |
- | stock | int(11) | YES | | NULL | |
- | id_category | int(11) | YES | | NULL | |
- | id_manufacturer | int(11) | YES | | NULL | |
- +-----------------+--------------+------+-----+---------+-------+
- 6 rows in set (0.00 sec)
- MariaDB [inventory]>
复制代码- MariaDB [inventory]> insert into product values (1 ,'SDSSDP-128G-G25 2.5',82.04, 30, 3,1 ) ;
- Query OK, 1 row affected (0.00 sec)
- MariaDB [inventory]> select * from product;
- +----+---------------------+-------+-------+-------------+-----------------+
- | id | name | price | stock | id_category | id_manufacturer |
- +----+---------------------+-------+-------+-------------+-----------------+
- | 1 | SDSSDP-128G-G25 2.5 | 82.04 | 30 | 3 | 1 |
- +----+---------------------+-------+-------+-------------+-----------------+
- 1 row in set (0.00 sec)
- MariaDB [inventory]>
复制代码- MariaDB [inventory]> select * from product where name like '%G%';
- +----+---------------------+-------+-------+-------------+-----------------+
- | id | name | price | stock | id_category | id_manufacturer |
- +----+---------------------+-------+-------+-------------+-----------------+
- | 1 | SDSSDP-128G-G25 2.5 | 89.9 | 60 | 3 | 1 |
- +----+---------------------+-------+-------+-------------+-----------------+
- 1 row in set (0.00 sec)
- MariaDB [inventory]> select * from product where name like '%F%';
- Empty set (0.00 sec)
- MariaDB [inventory]> select * from product where name like 'S_S%';
- +----+---------------------+-------+-------+-------------+-----------------+
- | id | name | price | stock | id_category | id_manufacturer |
- +----+---------------------+-------+-------+-------------+-----------------+
- | 1 | SDSSDP-128G-G25 2.5 | 89.9 | 60 | 3 | 1 |
- +----+---------------------+-------+-------+-------------+-----------------+
- 1 row in set (0.00 sec)
- MariaDB [inventory]> select * from product where name like 'S__S%';
- +----+---------------------+-------+-------+-------------+-----------------+
- | id | name | price | stock | id_category | id_manufacturer |
- +----+---------------------+-------+-------+-------------+-----------------+
- | 1 | SDSSDP-128G-G25 2.5 | 89.9 | 60 | 3 | 1 |
- +----+---------------------+-------+-------+-------------+-----------------+
- 1 row in set (0.00 sec)
- MariaDB [inventory]> select * from product where name like 'S___S%';
- Empty set (0.00 sec)
- MariaDB [inventory]>
复制代码- MariaDB [inventory]> select * from product where name like 'S___S%';
- Empty set (0.00 sec)
- MariaDB [inventory]> select * from product where id_category in ( 1, 2 ) ;
- Empty set (0.00 sec)
- MariaDB [inventory]> select * from product where id_category in ( 1, 2, 3);
- +----+---------------------+-------+-------+-------------+-----------------+
- | id | name | price | stock | id_category | id_manufacturer |
- +----+---------------------+-------+-------+-------------+-----------------+
- | 1 | SDSSDP-128G-G25 2.5 | 89.9 | 60 | 3 | 1 |
- +----+---------------------+-------+-------+-------------+-----------------+
- 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:- [root@server3 etc]# mysqldump -u root -p inventory > /root/inventory.mdb
- Enter password:
- [root@server3 etc]# cd
- [root@server3 ~]# vim inventory.mdb
- [root@server3 ~]#
复制代码
---------------------------------------------------
- MariaDB [inventory]> show tables;
- +---------------------+
- | Tables_in_inventory |
- +---------------------+
- | product |
- +---------------------+
- 1 row in set (0.00 sec)
- MariaDB [inventory]> select * from product;
- +----+---------------------+-------+-------+-------------+-----------------+
- | id | name | price | stock | id_category | id_manufacturer |
- +----+---------------------+-------+-------+-------------+-----------------+
- | 10 | SDSSDP-128G-G25 2.5 | 89.9 | 60 | 3 | 1 |
- +----+---------------------+-------+-------+-------------+-----------------+
- 1 row in set (0.00 sec)
- MariaDB [inventory]> drop table product;
- Query OK, 0 rows affected (0.01 sec)
- MariaDB [inventory]> show tables;
- Empty set (0.00 sec)
- MariaDB [inventory]> source /root/inventory2.mdb
- Query OK, 0 rows affected (0.01 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.01 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 1 row affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- Query OK, 0 rows affected (0.00 sec)
- MariaDB [inventory]> show tables;
- +---------------------+
- | Tables_in_inventory |
- +---------------------+
- | product |
- +---------------------+
- 1 row in set (0.00 sec)
- MariaDB [inventory]>
复制代码
|
|