diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-06.22\346\234\215\345\212\241\347\256\241\347\220\206.md" "b/05\346\237\257\346\230\200\345\220\253/2024-06.22-\346\234\215\345\212\241\347\256\241\347\220\206.md" similarity index 100% rename from "05\346\237\257\346\230\200\345\220\253/2024-06.22\346\234\215\345\212\241\347\256\241\347\220\206.md" rename to "05\346\237\257\346\230\200\345\220\253/2024-06.22-\346\234\215\345\212\241\347\256\241\347\220\206.md" diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-06.25-LInux\351\230\262\347\201\253\345\242\231.md" "b/05\346\237\257\346\230\200\345\220\253/2024-06.25-LInux\351\230\262\347\201\253\345\242\231.md" new file mode 100644 index 0000000000000000000000000000000000000000..f0b76106b1bf1ab89cfa67d0f37d5a56c784d6bf --- /dev/null +++ "b/05\346\237\257\346\230\200\345\220\253/2024-06.25-LInux\351\230\262\347\201\253\345\242\231.md" @@ -0,0 +1,37 @@ +# Linux防火墙 + +安装防火墙 + +``` +apt install ufw +``` + +查看端口 + +``` +ufw status +``` + +添加端口号 + +``` +ufw allow 端口号/协议 +``` + +禁用端口 + +``` +ufw deny 端口号 +``` + +删除端口 + +``` +ufw delete 行号 +``` + +重新加载防火墙 + +``` +ufw reload +``` \ No newline at end of file diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-07.02-debian\351\203\250\347\275\262apache\345\222\214\350\257\201\344\271\246.md" "b/05\346\237\257\346\230\200\345\220\253/2024-07.02-debian\351\203\250\347\275\262apache\345\222\214\350\257\201\344\271\246.md" new file mode 100644 index 0000000000000000000000000000000000000000..58f62362f19d1e412be5e5d1a8e3ba86ea966ad9 --- /dev/null +++ "b/05\346\237\257\346\230\200\345\220\253/2024-07.02-debian\351\203\250\347\275\262apache\345\222\214\350\257\201\344\271\246.md" @@ -0,0 +1,90 @@ +# Debian部署apache2和证书 + +一.安装apache2 + +``` +apt install apache2 +``` + +二.开启ssl模块 + +``` +sudo a2enmod ssl +``` + +三.在`/etc/apache2`创建一个文件夹存放3个证书 + +四.更改端口,如有需要步骤如下: + +``` +vim /etc/apache2/ports.conf +编辑如下: +# If you just change the port or add more ports here, you will likely also +# have to change the VirtualHost statement in +# /etc/apache2/sites-enabled/000-default.conf + +Listen 80 #访问端口,改成8080 + + + Listen 443 #访问https,改成444 + + + + Listen 443 + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet +``` + +如果是华为云服务器,则在华为云>安全组>添加8080端口 + +五.在`/etc/apache2/sites-enabled` + +1.删除default-ssl.conf文件 + +2.目录下创建一个为`域名.conf`的文件,在编辑如下 + +``` + + #https端口 + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + SSLEngine on + SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem + SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + + #默认端口 + ServerName qing05.com #自己的域名 + ServerAlias www.qing05.com #别名 + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html #显示网页的路径 + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + SSLEngine on + SSLHonorCipherOrder on + SSLProtocol TLSv1.1 TLSv1.2 TLSv1.3 + SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4 + SSLCertificateFile /etc/apache2/cert/public.crt #证书1 + SSLCertificateKeyFile /etc/apache2/cert/qing05.com.key #证书2 + SSLCertificateChainFile /etc/apache2/cert/qing05.com_chain.crt #证书3 + +``` + +如果是华为云则添加安全组规则 + +五.重启 + +``` +systemctl status apache2 #查看apache状态 +systemctl restart apache2 #重启apache +``` \ No newline at end of file diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-07.03-debian\345\256\211\350\243\205,\345\215\270\350\275\275mysql.md" "b/05\346\237\257\346\230\200\345\220\253/2024-07.03-debian\345\256\211\350\243\205,\345\215\270\350\275\275mysql.md" new file mode 100644 index 0000000000000000000000000000000000000000..4da9c868a4b89536cb844fd1f768825c12746a8e --- /dev/null +++ "b/05\346\237\257\346\230\200\345\220\253/2024-07.03-debian\345\256\211\350\243\205,\345\215\270\350\275\275mysql.md" @@ -0,0 +1,73 @@ +# Debian 安装mysql + +## 一.从网络上获取最新的安装包 + +``` +wget https://repo.mysql.com/mysql-apt-config_0.8.30-1_all.deb +sudo dpkg -i mysql-apt-config_0.8.30-1_all.deb +``` + +![alt text](https://gitee.com/Z3252085660/linux-fundamentals/raw/master/%E5%BC%A0%E5%A2%9E%E6%B6%9B/image/img004.png) + +![alt text](https://gitee.com/Z3252085660/linux-fundamentals/raw/master/%E5%BC%A0%E5%A2%9E%E6%B6%9B/image/img005.png) + +如果来回跳,安装成功 + +## 二.更新软件包并安装 + +``` +sudo apt update +sudo apt install mysql-server +``` + +安装过程中将会弹出设置 MySQL root 密码的对话框,设置root登入mysql的密码。 + +## 三.查看mysql运行状态 + +``` +systemctl status mysql +``` + +## 四.输入`mysql -u root -p`输入密码即可进入 + +## 五.设置远程登入mysql: + + 1.进入mysql :mysql -u root -p + + 2.mysql> use mysql; + + 3.mysql> update user set host='%' where user ='root' ; + + 4.mysql> flush privileges; + + 5.在'/etc/mysql/mysql.conf.d'目录下有mysqld.cnf,在最后加上:port =3307 + + 6.重启mysql:systemctl restart mysql + +## 六.远程登入mysql + +``` +mysql -h IP地址 -P 端口 -u root -p +``` + + + +# 卸载 + +列出所有MySql进程 + +dpkg -get-selections | grep mysql + +逐一卸载 + +apt-get --purge remove .... + +清楚残余 + +apt-get autoremove + +apt-get autoclean + +rm /etc/mysql/ -R + +rm /var/lib/mysql/ -R \ No newline at end of file diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-07.04-mysql\346\223\215\344\275\234.md" "b/05\346\237\257\346\230\200\345\220\253/2024-07.04-mysql\346\223\215\344\275\234.md" new file mode 100644 index 0000000000000000000000000000000000000000..a8e968def0e62f81d530a8e0add8fb4832fe342b --- /dev/null +++ "b/05\346\237\257\346\230\200\345\220\253/2024-07.04-mysql\346\223\215\344\275\234.md" @@ -0,0 +1,83 @@ +# mysql操作 + +修改密码 + +``` +mysqladmin -u root -p password '密码' +``` + +1.查看所有库 + +``` +show databases; +``` + +2.创建数据表 + +``` +create database 库名称; +``` + +3.切换数据库 + +``` +use 库名; +``` + +4.创建数据表 + +``` + create table student ( id int auto_increment primary key,#自增(auto_increment),主键(primary key) + name varchar(50), + sex char(1) null #可以为空 + ); +``` + +5.数据表的一些命令 + +``` +select * from 表名; +desc 表名; #查看表结构 +insert into student (name,sex) values('小马','男'); #增加数据 +update student set name='小王八' where id=5; #修改数据 +delete from student where id =2;#删除数据 +``` + +# mysql数据备份,还原 + +## 备份 + +1.备份多个库 + +``` +mysqldump -u root -p --databases 库名1 库名2 > 备份路径 +``` + +2.备份数据库里的表(只备份表,不备份数据库) + +``` +mysqldump -u root -p 库名 表名1 表名2> 备份路径 +``` + +3.只备份数据库结构 + +``` +mysqldump -u root -p --no-data mysql_test > 备份路径 +``` + +4.只备份数据,不备份结构 + +``` +mysqldump -u root -p --no-create-info mysql_test > 备份路径 +``` + +## 还原 + +``` +方法一: +1.先切好到要还原的数据库:use 库名;如果备份的是数据库无需切换 +2.source 备份的路径(绝对路径) +方法二: +前提是必须有这个库 +mysql -u root -p 库名 < 要恢复文件的路径 +``` \ No newline at end of file diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-07.06-\345\256\211\350\243\205postgresql.md" "b/05\346\237\257\346\230\200\345\220\253/2024-07.06-\345\256\211\350\243\205postgresql.md" new file mode 100644 index 0000000000000000000000000000000000000000..64651b00917213a30646acca20984571e493cbc0 --- /dev/null +++ "b/05\346\237\257\346\230\200\345\220\253/2024-07.06-\345\256\211\350\243\205postgresql.md" @@ -0,0 +1,33 @@ +# 安装postgresql + +``` +apt update +apt install -y postgresql-common +/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh +apt install postgresql +``` + +更改配置文件 + +在`/etc/postgresql/16/main`目录下更改两个配置文件:`pg_hba.conf`,`postgresql.conf` + +``` +pg_hba.conf: +在一下注释添加代码 +# IPv4 local connections: +host all all 0.0.0.0/0 scram-sha-256 +postgresql.conf: +listen_addresses = '*' 把注释移除,并改成这样 +添加密码:su post +postgres=# \password +``` + +# 语法 + +``` +远程连接:psql -U postgres -d 数据库 -h Ip地址 +\l #查看所有数据库 +\c 数据库 #切换数据库 +\dt #显示所有表 +\d #小时表结构 +``` \ No newline at end of file diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-07.09-postgresql\346\225\260\346\215\256\345\272\223\345\244\207\344\273\275\350\277\230\345\216\237.md" "b/05\346\237\257\346\230\200\345\220\253/2024-07.09-postgresql\346\225\260\346\215\256\345\272\223\345\244\207\344\273\275\350\277\230\345\216\237.md" new file mode 100644 index 0000000000000000000000000000000000000000..a1c98f45afe1cafd55c4df2dd7e033b955227ce8 --- /dev/null +++ "b/05\346\237\257\346\230\200\345\220\253/2024-07.09-postgresql\346\225\260\346\215\256\345\272\223\345\244\207\344\273\275\350\277\230\345\216\237.md" @@ -0,0 +1,20 @@ +# postgres数据库备份、还原 + +## 备份 + +``` +1.库备份 + pg_dump -U postgres -d 备份的数据库名 > 备份路径 +2.表备份 + pg_dump -U postgres -d 备份的数据库名 -t 表名1 -t 表名2> 备份路径 +3.备份所有库 + pg_dumpall > 备份路径 +``` + +## 还原 + +``` +psql -h IP地址 -U postgres -d 要恢复的数据库 < 备份路径 +恢复所有备份的数据库: +psql < 备份路径 +``` \ No newline at end of file diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-07.10-shell\350\204\232\346\234\254.md" "b/05\346\237\257\346\230\200\345\220\253/2024-07.10-shell\350\204\232\346\234\254.md" new file mode 100644 index 0000000000000000000000000000000000000000..89520a7773ea998a2e46c37ca6f602f3cb06e43a --- /dev/null +++ "b/05\346\237\257\346\230\200\345\220\253/2024-07.10-shell\350\204\232\346\234\254.md" @@ -0,0 +1,31 @@ +# shell脚本 + +一.写脚本 + + sheel脚本文件一般以`.sh`结尾 + + 文件内容第一句话为:`#!/bin/bash` + +二.执行shell脚本 + + 1.以绝对路径执行,需要加上可执行权限 + + 2.bash shell.she 不需要加权限 + +三.检查脚本 + + 1.bash -x 脚本 检测脚本语法是否正确 + + 2.bash -n 脚本 只显示语法错误的信息 + +四.位置变量 + + 指的是从命令行传递给脚本或函数的参数。每个参数都有一个编号,从 0开始,其中0开始,其中0 是脚本本身的名字,而 1、1、2、$3 等依次对应第一个、第二个、第三个参数等。 + +``` +echo "脚本的文件名 $0" #会打印出脚本的文件名 +echo "$1" #脚本后面的第一个参数 +echo "$2" #脚本后面的第二个参数 +echo "$3" #脚本后面的第三个参数 +echo "${10}" #脚本后面的第十个参数 +``` \ No newline at end of file