Update from Sync Service

This commit is contained in:
FNS Service
2026-04-15 23:43:17 +08:00
parent 6d17896267
commit ae67147f29
274 changed files with 4895 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
1. ==Install the repository RPM:========yum install== ==https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm==
2. ==Install the client packages:========yum install postgresql12==
3. ==Optionally install the server packages:========yum install postgresql12-server==
4. ==Optionally initialize the database and enable automatic start:========/usr/pgsql-12/bin/postgresql-12-setup initdb========systemctl enable postgresql-12========systemctl start postgresql-12== \> 来自 \<[https://www.postgresql.org/download/linux/redhat/](https://www.postgresql.org/download/linux/redhat/)\>
[Service]
Type=notify
User=postgres
Group=postgres
# Note: avoid inserting whitespace in these Environment= lines, or you may
# break postgresql-setup.
# Location of database directory
Environment=PGDATA=/var/lib/pgsql/12/data/
初始化之后,数据文件会存在 /var/lib/pgsql/12/data
\> 来自 \<[https://www.postgresql.org/download/linux/redhat/](https://www.postgresql.org/download/linux/redhat/)\>

View File

@@ -0,0 +1,4 @@
==#su postgres== ======-bash-3.2$psql - postgres== ======postgres=#alter user postgres with password 'new password';== ==////====一定要加分号执行========postgres=#\q==
su - postgres
psql -U postgresalter user postgres with encrypted password '1';

View File

@@ -0,0 +1,11 @@
METHOD指定如何处理客户端的认证。常用的有identmd5passwordtrustreject
ident是Linux下PostgreSQL默认的local认证方式凡是能正确登录服务器的操作系统用户不是数据库用户就能使用本用户映射的数据库用户不需密码登录数据库。用户映射文件为pg_ident.conf这个文件记录着与操作系统用户匹配的数据库用户如果某操作系统用户在本文件中没有映射用户则默认的映射数据库用户与操作系统用户同名。比如服务器上有名为user1的操作系统用户同时数据库上也有同名的数据库用户user1登录操作系统后可以直接输入psql以user1数据库用户身份登录数据库且不需密码。很多初学者都会遇到psql -U username登录数据库却出现“username ident 认证失败”的错误明明数据库用户已经createuser。原因就在于此使用了ident认证方式却没有同名的操作系统用户或没有相应的映射用户。解决方案1、在pg_ident.conf中添加映射用户2、改变认证方式。
md5是常用的密码认证方式如果你不使用ident最好使用md5。密码是以md5形式传送给数据库较安全且不需建立同名的操作系统用户。
password是以明文密码传送给数据库建议不要在生产环境中使用。
trust是只要知道数据库用户名就不需要密码或ident就能登录建议不要在生产环境中使用。
reject是拒绝认证。
在文件查找 listen_addresses他的值说明
如果希望只能从本地计算机访问PostgreSQL数据库就将该项设置为'localhost'
如果希望从局域网访问PostgreSQL数据库就将该项设置为PostgreSQL数据库的局域网IP地址
如果希望从互联网访问PostgreSQL数据库就将该项设置为PostgreSQL数据库的互联网IP地址
如果希望从任何地方都可以访问PostgreSQL数据库就将该配置项设置为“*”;

View File

@@ -0,0 +1,3 @@
select `pg_terminate_backend(pid)` from `pg_stat_activity` where `datname`='testdb' and `pid`\<\>`pg_backend_pid();`
==上面sql表示的是关闭数据库testdb的活动连接接下来就可以用==
drop database `testdb;`

View File

@@ -0,0 +1 @@
systemctl start postgresql-12.service // 启动服务systemctl stop postgresql-12.service // 关闭服务systemctl restart postgresql-12.service // 重启服务systemctl status postgresql-12.service // 查看状态