diff --git "a/\345\274\240\345\242\236\346\266\233/20240622-\346\234\215\345\212\241\347\256\241\347\220\206.md" "b/\345\274\240\345\242\236\346\266\233/20240622-\346\234\215\345\212\241\347\256\241\347\220\206.md" index 93910890369472788961b74ac97099498cf0442f..cd0eaa09df1250da0b6e9baa7286d4c1bfaff508 100644 --- "a/\345\274\240\345\242\236\346\266\233/20240622-\346\234\215\345\212\241\347\256\241\347\220\206.md" +++ "b/\345\274\240\345\242\236\346\266\233/20240622-\346\234\215\345\212\241\347\256\241\347\220\206.md" @@ -7,7 +7,7 @@ ```bash systemctl start 服务名 #开启某服务名称 systemctl stop 服务名 #关闭某服务名称 -systemctl restar 服务名 #重启某服务名称 +systemctl restart 服务名 #重启某服务名称 systemctl status 服务名 #查看服务状态 systemctl enalbe 服务名 #开机自启动服务 ``` diff --git "a/\345\274\240\345\242\236\346\266\233/20240625-Linux\351\230\262\347\201\253\345\242\231.md" "b/\345\274\240\345\242\236\346\266\233/20240625-Linux\351\230\262\347\201\253\345\242\231.md" new file mode 100644 index 0000000000000000000000000000000000000000..1d22fbde0df5daca758ad5ab983e5fdf130e992e --- /dev/null +++ "b/\345\274\240\345\242\236\346\266\233/20240625-Linux\351\230\262\347\201\253\345\242\231.md" @@ -0,0 +1,38 @@ +# Linux防火墙 + +安装防火墙 + +```bash +apt install ufw +``` + +查看端口 + +```bash +ufw status +``` + +添加端口号 + +```bash +ufw allow 端口号/协议 +``` + +禁用端口 + +```bash +ufw deny 端口号 +``` + +删除端口 + +```bash +ufw delete 行号 +``` + +重新加载防火墙 + +```bash +ufw reload +``` + diff --git "a/\345\274\240\345\242\236\346\266\233/20240702-Debian\351\203\250\347\275\262apache2\345\222\214\350\257\201\344\271\246.md" "b/\345\274\240\345\242\236\346\266\233/20240702-Debian\351\203\250\347\275\262apache2\345\222\214\350\257\201\344\271\246.md" new file mode 100644 index 0000000000000000000000000000000000000000..1a2bc08381d91886bf7ebb06d63f29d44e22f100 --- /dev/null +++ "b/\345\274\240\345\242\236\346\266\233/20240702-Debian\351\203\250\347\275\262apache2\345\222\214\350\257\201\344\271\246.md" @@ -0,0 +1,93 @@ +# Debian部署apache2和证书 + +一.安装apache2 + +```bash +apt install apache2 +``` + +二.开启ssl模块 + +```bash +sudo a2enmod ssl +``` + +三.在`/etc/apache2`创建一个文件夹存放3个证书 + +四.更改端口,如有需要步骤如下: + +```bash +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`的文件,在编辑如下 + +```bash + + #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 + +``` + +如果是华为云则添加安全组: + +![alt text](./image/Db001.png) + +五.重启 + +```bash +systemctl status apache2 #查看apache状态 +systemctl restart apache2 #重启apache +``` + diff --git "a/\345\274\240\345\242\236\346\266\233/20240702-Linux\350\241\245\345\205\205\345\221\275\344\273\244.md" "b/\345\274\240\345\242\236\346\266\233/20240702-Linux\350\241\245\345\205\205\345\221\275\344\273\244.md" new file mode 100644 index 0000000000000000000000000000000000000000..b86f1205984e906afda4e05c2d6d608664795509 --- /dev/null +++ "b/\345\274\240\345\242\236\346\266\233/20240702-Linux\350\241\245\345\205\205\345\221\275\344\273\244.md" @@ -0,0 +1,78 @@ +# 补充命令 + +### 一.排序sort + +- 默认说以每一行第一个字符的ASCII码,升序 +- 数字在字母前 +- -r 倒序 +- -k2 比较第2列 +- -k2.2 比较第二列的第二个字符 +- 如果比较的是数字的大小,一般会 -n +- -u 去重 + +### 二.去重uniq + +- 先sort排序 +- 后uniq +- -c 显示重复次数 + +### 三.wc -l 统计文件数 | 内容行数 + +- nl +- cat -n +- vim :set u 显示行号 + +### 四.cut + +- -d 指定分割符 +- -f 指定要的列 +- -f M,N +- -f M-N + +### 五.三剑客: + +#### grep + +- 本意是显示匹配的关键字所在的行(模糊搜索) +- 过滤 +- -A2 后2行 +- -B2 前2行 +- -C2 前后2行 + +#### sed + +- 增加 + - 行加 2i\内容 + - 匹配加 /www/i\内容 + - 后加a\内容 + - 行2a\内容 + - 匹配 /www/a\内容 + +#### 多个选项一起 -e 选项 -e 选项 + +#### 删除: + +- d + - 删除行 2d + - 删除匹配的行/关键字/d + +#### 修改: + +- s/旧/新/ 将每一行第一个旧,换成新 +- s/旧/新/g 将每一行第一个旧,换成新 + +#### 保存 + +- -i + +#### 查找: + +- /要查找的内容/p -n + +#### awk + +- ``` + awk -F 分割符 'BEGIN{动作} 条件模式{动作} EDN{动作}' 文件 + ``` + +column -t :文件名将文件内容以表格显示 \ No newline at end of file diff --git "a/\345\274\240\345\242\236\346\266\233/20240703-Debian \345\256\211\350\243\205mysql.md" "b/\345\274\240\345\242\236\346\266\233/20240703-Debian \345\256\211\350\243\205mysql.md" new file mode 100644 index 0000000000000000000000000000000000000000..47c4889ff9a08811303179ae51657674d5a9bd47 --- /dev/null +++ "b/\345\274\240\345\242\236\346\266\233/20240703-Debian \345\256\211\350\243\205mysql.md" @@ -0,0 +1,55 @@ +# Debian 安装mysql + +## 一.从网络上获取最新的安装包 + +```bash +wget https://repo.mysql.com/mysql-apt-config_0.8.30-1_all.deb +``` + +```bash +sudo dpkg -i mysql-apt-config_0.8.30-1_all.deb +``` + +![alt text](./image/img004.png) + +![alt text](./image/img005.png) + +如果来回跳,安装成功 + +## 二.更新软件包并安装 + +```bash +sudo apt update +sudo apt install mysql-server +``` + +安装过程中将会弹出设置 MySQL root 密码的对话框,设置root登入mysql的密码。 + +## 三.查看mysql运行状态 + +```bash +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 + +```bash +mysql -h IP地址 -P 端口 -u root -p +``` + diff --git "a/\345\274\240\345\242\236\346\266\233/20240704-mysql\346\223\215\344\275\234.md" "b/\345\274\240\345\242\236\346\266\233/20240704-mysql\346\223\215\344\275\234.md" new file mode 100644 index 0000000000000000000000000000000000000000..c357c0cee8e5f31ad8ce8699989af4acc87a61d8 --- /dev/null +++ "b/\345\274\240\345\242\236\346\266\233/20240704-mysql\346\223\215\344\275\234.md" @@ -0,0 +1,89 @@ +# mysql操作 + +修改密码 + +``` +mysqladmin -u root -p password '密码' +``` + +1.查看所有库 + +```sql +show databases; +``` + +2.创建数据表 + +```sql +create database 库名称; +``` + +3.切换数据库 + +```sql +use 库名; +``` + +4.创建数据表 + +```sql + create table student ( id int auto_increment primary key,#自增(auto_increment),主键(primary key) + name varchar(50), + sex char(1) null #可以为空 + ); +``` + +5.数据表的一些命令 + +```sql +select * from 表名; +desc 表名; #查看表结构 +insert into student (name,sex) values('小马','男'); #增加数据 +update student set name='小王八' where id=5; #修改数据 +delete from student where id =2;#删除数据 +``` + +# mysql数据备份,还原 + +## 备份 + +1.备份多个库 + +```bahs +mysqldump -u root -p --databases 库名1 库名2 > 备份路径 +``` + +2.备份数据库里的表(只备份表,不备份数据库) + +``` +mysqldump -u root -p 库名 表名1 表名2> 备份路径 +``` + +3.只备份数据库结构 + +```bash +mysqldump -u root -p --no-data mysql_test > 备份路径 +``` + +4.只备份数据,不备份结构 + +```bash +mysqldump -u root -p --no-create-info mysql_test > 备份路径 +``` + + + +## 还原 + +``` +方法一: +1.先切好到要还原的数据库:use 库名;如果备份的是数据库无需切换 +2.source 备份的路径(绝对路径) +``` + +```bash +方法二: +前提是必须有这个库 +mysql -u root -p 库名 < 要恢复文件的路径 +``` + diff --git "a/\345\274\240\345\242\236\346\266\233/20240706-\345\256\211\350\243\205postgresql.md" "b/\345\274\240\345\242\236\346\266\233/20240706-\345\256\211\350\243\205postgresql.md" new file mode 100644 index 0000000000000000000000000000000000000000..9cf01e78153ec121271dee27098bcecf18054232 --- /dev/null +++ "b/\345\274\240\345\242\236\346\266\233/20240706-\345\256\211\350\243\205postgresql.md" @@ -0,0 +1,25 @@ +# 安装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 = '*' 把注释移除,并改成这样 +``` + diff --git "a/\345\274\240\345\242\236\346\266\233/image/DB001.png" "b/\345\274\240\345\242\236\346\266\233/image/DB001.png" new file mode 100644 index 0000000000000000000000000000000000000000..4aea3ea38a25bd04b25b86ea2cececda97bf4b73 Binary files /dev/null and "b/\345\274\240\345\242\236\346\266\233/image/DB001.png" differ diff --git "a/\345\274\240\345\242\236\346\266\233/image/img004.png" "b/\345\274\240\345\242\236\346\266\233/image/img004.png" new file mode 100644 index 0000000000000000000000000000000000000000..ae6380511e324ef116c9c915ee56d9a1601d5870 Binary files /dev/null and "b/\345\274\240\345\242\236\346\266\233/image/img004.png" differ diff --git "a/\345\274\240\345\242\236\346\266\233/image/img005.png" "b/\345\274\240\345\242\236\346\266\233/image/img005.png" new file mode 100644 index 0000000000000000000000000000000000000000..884d38958ad686edf68b30da3395499ee245639d Binary files /dev/null and "b/\345\274\240\345\242\236\346\266\233/image/img005.png" differ