diff --git "a/07\351\203\221\345\255\220\346\235\260/2024\345\271\26407\346\234\21006\346\227\245\347\254\224\350\256\260-linux\345\237\272\347\241\20020(\345\256\211\350\243\205postgresql).md" "b/07\351\203\221\345\255\220\346\235\260/2024\345\271\26407\346\234\21006\346\227\245\347\254\224\350\256\260-linux\345\237\272\347\241\20020(\345\256\211\350\243\205postgresql).md" new file mode 100644 index 0000000000000000000000000000000000000000..da36964ef512a210c70271942518bc42df29510d --- /dev/null +++ "b/07\351\203\221\345\255\220\346\235\260/2024\345\271\26407\346\234\21006\346\227\245\347\254\224\350\256\260-linux\345\237\272\347\241\20020(\345\256\211\350\243\205postgresql).md" @@ -0,0 +1,46 @@ +# 安装postgresql + +```bash +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/07\351\203\221\345\255\220\346\235\260/2024\345\271\26407\346\234\21009\346\227\245\347\254\224\350\256\260-linux\345\237\272\347\241\20021(\346\225\260\346\215\256\345\272\223\345\244\207\344\273\275\350\277\230\345\216\237).md" "b/07\351\203\221\345\255\220\346\235\260/2024\345\271\26407\346\234\21009\346\227\245\347\254\224\350\256\260-linux\345\237\272\347\241\20021(\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..7e2c7a5b50c6a364385a3f69dac9313c3f119bd5 --- /dev/null +++ "b/07\351\203\221\345\255\220\346\235\260/2024\345\271\26407\346\234\21009\346\227\245\347\254\224\350\256\260-linux\345\237\272\347\241\20021(\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,24 @@ +# postgres数据库备份、还原 + +## 备份 + +```bash +1.库备份 + pg_dump -U postgres -d 备份的数据库名 > 备份路径 +2.表备份 + pg_dump -U postgres -d 备份的数据库名 -t 表名1 -t 表名2> 备份路径 +3.备份所有库 + pg_dumpall > 备份路径 +``` + + + +## 还原 + +```bash +psql -h IP地址 -U postgres -d 要恢复的数据库 < 备份路径 +恢复所有备份的数据库: +psql < 备份路径 +``` + + \ No newline at end of file diff --git "a/07\351\203\221\345\255\220\346\235\260/2024\345\271\26407\346\234\21010\346\227\245\347\254\224\350\256\260-linux\345\237\272\347\241\20022(shell\350\204\232\346\234\254).md" "b/07\351\203\221\345\255\220\346\235\260/2024\345\271\26407\346\234\21010\346\227\245\347\254\224\350\256\260-linux\345\237\272\347\241\20022(shell\350\204\232\346\234\254).md" new file mode 100644 index 0000000000000000000000000000000000000000..af395de9444d644ccd8a49ab7cfdc1b929c8158a --- /dev/null +++ "b/07\351\203\221\345\255\220\346\235\260/2024\345\271\26407\346\234\21010\346\227\245\347\254\224\350\256\260-linux\345\237\272\347\241\20022(shell\350\204\232\346\234\254).md" @@ -0,0 +1,30 @@ +# shell脚本 + +一.写脚本 + +​ sheel脚本文件一般以`.sh`结尾 + +​ 文件内容第一句话为:`#!/bin/bash` + +二.执行shell脚本 + +​ 1.以绝对路径执行,需要加上可执行权限 + +​ 2.bash shell.she 不需要加权限 + +三.检查脚本 + +​ 1.bash -x 脚本 检测脚本语法是否正确 + +​ 2.bash -n 脚本 只显示语法错误的信息 + +四.位置变量 + +​ 指的是从命令行传递给脚本或函数的参数。每个参数都有一个编号,从 $0 开始,其中 $0 是脚本本身的名字,而 $1、$2、$3 等依次对应第一个、第二个、第三个参数等。 + +```bash +echo "脚本的文件名 $0" #会打印出脚本的文件名 +echo "$1" #脚本后面的第一个参数 +echo "$2" #脚本后面的第二个参数 +echo "$3" #脚本后面的第三个参数 +echo "${10}" #脚本后面的第十个参数 \ No newline at end of file