diff --git "a/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240625-\347\275\221\347\273\234\346\234\215\345\212\241.md" "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240625-\347\275\221\347\273\234\346\234\215\345\212\241.md" new file mode 100644 index 0000000000000000000000000000000000000000..1268cdf4506a9a18b207cdb2b3bb86051724a749 --- /dev/null +++ "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240625-\347\275\221\347\273\234\346\234\215\345\212\241.md" @@ -0,0 +1,74 @@ +### 网络服务 + +1. 查看IP + + ```bash + ip address #查看IP地址 + ip route #查看路由表信息 + ``` + +2. 下载文件 + + ```bash + wget 下载文件的链接 + curl -O 下载文件的链接 #下载并保存文件 + ``` + +3. ssh远程登录、 + + ```bash + ssh 用户名@主机 + ssh -l 用户名 主机 + ``` + +4. ss命令 + + ```bash + ss -ltp #查看进程号和进程名 + ss -tunl #以数字形式显示正在监听的TCP和UDP端口 + ss -tuna #以数字形式显示所有TCP、UDP端口(包含监听的和已连接的) + ``` + +5. 通过进程号反查服务名 + + ```bash + ps -ef | grep 进程号 + ps aux | grep 进程号 + ss -p | grep 进程号 + ``` + +6. 结束服务的所有进程 + + ```bash + killall 服务名 + pkill -9 服务名 + ``` + +7. 统计文件个数:wc -l + +8. 网络安全:端口安全,禁止非法访问端口,只允许指定的端口开放 + +9. Linux主流: + + - RedHat:redhat、centos + - rpm包 + - yum安装 + - 防火墙(iptables=>firewalls) + - Debian:debain、Ubuntu + - .deb包 dpkg包 + - apt安装 + - 防火墙ufw + +### 防火墙 + +1. 是一种安全机制,不被允许的端口都是默认禁止 + + ```bash + ufw status #查看防火墙状态 + ufw allow 端口号/协议 #允许开放该端口和协议 + ufw delete 行号 #删除这一行端口的防火墙 + ufw reload #重新加载 + ufw deny 端口号/协议 #禁用该协议端口 + ``` + + \ No newline at end of file diff --git "a/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240702-apache\345\256\211\350\243\205\345\217\212ssl\350\257\201\344\271\246\351\203\250\347\275\262.md" "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240702-apache\345\256\211\350\243\205\345\217\212ssl\350\257\201\344\271\246\351\203\250\347\275\262.md" new file mode 100644 index 0000000000000000000000000000000000000000..ebd8e1b8d7ab18db773db479be0c4a75e2216902 --- /dev/null +++ "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240702-apache\345\256\211\350\243\205\345\217\212ssl\350\257\201\344\271\246\351\203\250\347\275\262.md" @@ -0,0 +1,90 @@ +### 一、Apache2下载 + +1. apt install apache2 + +2. 查看状态: systemctl status apache2。80端口被nginx占用了 + +3. 修改端口,与nginx共享:vim /etc/apache2/ ports.conf + + ```bash + # 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 8080 #将端口修改为8080 + + + Listen 444 + + + + Listen 444 + + ``` + +4. 在华为云安全组添加8080端口和444端口 + +5. 修改端口和添加网站地址(域名):/etc/apache2/sites-available/000-default.conf 或者这个文件/etc/apache2/sites-enabled/000-default.conf 他们会同步,改其中一个就会同步一起改 + + ```bash + + ServerName lckhai.cn #里面有这句话,解注后再修改成自己的域名就行 + + ``` + +6. 防火墙开启端口: + + ```bash + ufw allow 8080 + ufw allow 444 + ``` + +7. 启用apache:systemctl status apache2 + +5. 查看状态: systemctl status apache2。正在运行 + +### 二、Apache2部署SSL证书 + +1. 在服务器下载证书 + + ```bash + 1. 在华为云的云证书管理服务控制台下载证书 + 2. 解压 + 3. 新建一个文件夹为cert,上传该证书到这个文件夹 + ``` + + +2. 在/etc/apache2/sites-available/default-ssl.conf下把端口号80改为444 + + ```bash + + ``` + +3. 在/etc/apache2/sites-enabled下新建一个文件为ssl.conf + + ```bash + + ServerName lckhai.cn #写自己的网站(域名)http + ServerAlias www.lckhai.cn #写自己的网站(域名)https + 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/server.crt #对应SSLCertificateFile的具体路径 + SSLCertificateKeyFile /etc/apache2/cert/server.key #对应SSLCertificateKeyFile的具体路径 + SSLCertificateChainFile /etc/apache2/cert/ca.crt #对SSLCertificateChainFile的具体路径 + + ``` + +4. 开启防火墙允许Apache2端口访问 + + ```bash + ufw allow 444 + ufw allow 8080 + ``` + + \ No newline at end of file diff --git "a/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240703-\345\256\211\350\243\205MySQL\345\217\212\351\205\215\347\275\256\345\205\201\350\256\270\350\277\234\347\250\213\347\231\273\345\275\225.md" "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240703-\345\256\211\350\243\205MySQL\345\217\212\351\205\215\347\275\256\345\205\201\350\256\270\350\277\234\347\250\213\347\231\273\345\275\225.md" new file mode 100644 index 0000000000000000000000000000000000000000..4d309c620ea2e28cbbf387fcd71be9043e159705 --- /dev/null +++ "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240703-\345\256\211\350\243\205MySQL\345\217\212\351\205\215\347\275\256\345\205\201\350\256\270\350\277\234\347\250\213\347\231\273\345\275\225.md" @@ -0,0 +1,65 @@ +### 安装MySQL及配置允许远程登录 + +#### 一、安装MySQL + +1. 更新资源: + + ```bash + apt update + ``` + +2. 从官网下载MySQL包 + + ```bash + wget http://repo.mysql.com/mysql-apt-config_0.8.30-1_all.deb + ``` + +3. 安装 + + ```bash + dpkg -i mysql-apt-config_0.8.30-1_all.deb组件 + ``` + +4. 安装mysql-server组件 + + ```bash + apt update #更新资源 + apt install mysql-server -y + ``` + +5. 弹出来的窗口默认原本选择就行 + +6. 设置root密码用来登录mysql + +7. 登录mysql + + ```bash + mysql -u root -p + 输入前面设置的root密码 + ``` + +#### 二、配置远程登录 + +1. 要先选择库 + + ```bash + show databases;#查看库 + use mysql + ``` + +2. 授权远程登录 + + ```bash + update user set host='%' where user='root';#允许所有人远程连接 + GRANT ALL PRIVTLEGES ON *.* TO 'root'@'%'; + GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' WITH GRANT OPTION;#赋予所有权限 + FLUSH PRIVILEGES;#刷新权限列表 + ``` + +3. 配置防火墙允许MySQL端口进入 + + ```bash + ufw allow 3306 + ``` + + \ No newline at end of file diff --git "a/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240703-\345\256\211\350\243\205postgresql\345\217\212\351\205\215\347\275\256\345\205\201\350\256\270\350\277\234\347\250\213\347\231\273\345\275\225.md" "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240703-\345\256\211\350\243\205postgresql\345\217\212\351\205\215\347\275\256\345\205\201\350\256\270\350\277\234\347\250\213\347\231\273\345\275\225.md" new file mode 100644 index 0000000000000000000000000000000000000000..c6a30d81c21f92a12de962d347ae0369d32832d0 --- /dev/null +++ "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240703-\345\256\211\350\243\205postgresql\345\217\212\351\205\215\347\275\256\345\205\201\350\256\270\350\277\234\347\250\213\347\231\273\345\275\225.md" @@ -0,0 +1,67 @@ +### 一、安装postgresql数据库 + +1. apt install postgresql -y + +### 二、配置允许远程连接登录 + +1. 切换用户 + + ```bash + su postgres + ``` + +2. 打开psql + + ```bash + psql -U postgres + ``` + +3. 设置密码 + + ```bash + ALTER USER postgres PASSWORD '写密码' + ``` + +4. 退出:\q + +5. 重新登录验证密码 + + ```bash + psql -U postgres -W + 输密码 + ``` + + 前面这几个弄好就可以用新密码进行本地登录postgresql + +6. 远程登录修改两个配置文件 + +7. 修改/etc/postgresql/13/main/pg_hba.conf + + ```bash + # pg_hba.conf文件找到IPv4增加 + host all all 0.0.0.0/0 md5 + ``` + +8. 修改/etc/postgresql/13/main/postgresql.conf + + ```bash + 1. 搜索/listen_addresses / + 2. 解注释,并改为listen_addresses = '*' + ``` + +9. 查看PostgreSQL占用的端口 + + ```bash + ss -tunpl + tcp LISTEN 0 244 [::1]:5432 [::]:* + users:(("postgres",pid=1467524,fd=5)) + ``` + +10. 设置防火墙允许PostgreSQL端口通过 + + ```bash + ufw allow 5432/tcp + ``` + + + diff --git "a/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240703-\346\225\260\346\215\256\345\272\223\347\232\204\345\242\236\345\210\240\346\224\271\346\237\245.md" "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240703-\346\225\260\346\215\256\345\272\223\347\232\204\345\242\236\345\210\240\346\224\271\346\237\245.md" new file mode 100644 index 0000000000000000000000000000000000000000..f1d9a7581552a66d6bb69bf1acfb6fe4e17e34fc --- /dev/null +++ "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240703-\346\225\260\346\215\256\345\272\223\347\232\204\345\242\236\345\210\240\346\224\271\346\237\245.md" @@ -0,0 +1,51 @@ +### 数据库的增删改查 + +#### 一、增 + +```bash +insert into 表名 (字段1,字段2,字段3.....)values (字段1的值,字段2的值......); +#值要与字段一一对应 +#一次插入多行数据 +insert into 表名 (字段1,字段2,字段3.....)values +(字段1的值,字段2的值......), +(字段1的值,字段2的值......), +...... +(字段1的值,字段2的值......); +``` + + + +#### 二、删 + +```bash +delete from 表名 #删除整个表 +delete from 表名 where 条件 #删除满足整个条件的字段 +``` + + + +#### 三、改 + +```bash +update 表名 set 修改内容 where 条件 +``` + + + +#### 四、查 + +```bash +select 指定要查询的列 from 表名 +1. select * from 表名;#查询整个表的内容 +2. select distinct 字段 from 表名 ;#去重 +3. select * from 表名 order by 字段 ;#排序order by 默认升序,降序desc +4. select * from 表名 where 字段 like '通配符';#模糊查询 +``` + +#### 通配符 + +1. %:可以代替任意字符 +2. t%:找出以t开头的字符串 +3. %t:找出以t结尾的字符串 +4. %t%:包含t的字符串 +5. ’_‘:一个下划线代表一个字符 \ No newline at end of file diff --git "a/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240704-\346\225\260\346\215\256\345\272\223\347\232\204\345\244\207\344\273\275\344\270\216\350\277\230\345\216\237.md" "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240704-\346\225\260\346\215\256\345\272\223\347\232\204\345\244\207\344\273\275\344\270\216\350\277\230\345\216\237.md" new file mode 100644 index 0000000000000000000000000000000000000000..d017b0683ca56599f5dcf81d14c0fe6ecc5579a3 --- /dev/null +++ "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240704-\346\225\260\346\215\256\345\272\223\347\232\204\345\244\207\344\273\275\344\270\216\350\277\230\345\216\237.md" @@ -0,0 +1,29 @@ +### 数据库的备份与还原 + +#### 一、备份 + +1. 备份工具:mysqldump + + ```bash + 1. 单库备份 #不包含建库语句,恢复时要指定数据库 + mysqldump -u root(用户名) -p 备份文件的名字(库名)> 要备份文件到的的具体路径.sql + #恢复的方法:1 先指定数据库 2.再添加建库语句 + 2. 多库备份 + mysqldump -u root -p --databases 库名1 库名2 库名3.。。。> 要备份文件到的的具体路径.sql + #还原时多库有建库语句,不用添加,不用指定库 + 3. 所有库备份 + mysqldump -u root -p --all-databases >要备份文件到的的具体路径.sql + 4. 单表备份 + mysqldump -u root -p 表所在的库名 表名 > 要备份文件到的的具体路径.sql + 5. 多表备份 + mysqldump -u root -p 表所在的库名 表名1 表名2 表名3。。。。 > 要备份文件到的的具体路径.sql + 6. 只备份库结构不备份数据 + mysqldump -u root -p --no-date 库名 > 要备份文件到的的具体路径.sql + ``` + + + +#### 二、还原 + +1. mysql -u root -p < 还原文件(恢复的文件的具体路径) +2. 登录mysql,先use要恢复的库,在source要恢复的文件 \ No newline at end of file diff --git "a/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240706-postgresql\347\232\204\345\270\270\347\224\250\345\221\275\344\273\244.md" "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240706-postgresql\347\232\204\345\270\270\347\224\250\345\221\275\344\273\244.md" new file mode 100644 index 0000000000000000000000000000000000000000..dcff9cab2a2223e81b3cd26b0f527d75e005055b --- /dev/null +++ "b/33 \346\236\227\347\247\200\346\270\205/\347\254\224\350\256\260/20240706-postgresql\347\232\204\345\270\270\347\224\250\345\221\275\344\273\244.md" @@ -0,0 +1,22 @@ +### postgresql的常用命令 + +1. 常用命令 + + ```bash + 1. 退出 \q + 2. 显示表 \dt + 3. 列出所有表 \l + 4. 查看表结构 \dt + 5. 切换数据库 \c + ``` + +2. 本地登陆 + + ```bash + 1. 切换用户postgresql + su postgres + 2. 连接本地数据库 + psql #本地登陆不需要密码 + ``` + + \ No newline at end of file