Update from Sync Service
This commit is contained in:
11
数据库/PostgreSQL/PostgreSQL_hba配置.md
Executable file
11
数据库/PostgreSQL/PostgreSQL_hba配置.md
Executable file
@@ -0,0 +1,11 @@
|
||||
METHOD指定如何处理客户端的认证。常用的有ident,md5,password,trust,reject
|
||||
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数据库,就将该配置项设置为“*”;
|
||||
7
数据库/PostgreSQL/PostgreSQL_postgresql删除还有活动连接的数据库.md
Executable file
7
数据库/PostgreSQL/PostgreSQL_postgresql删除还有活动连接的数据库.md
Executable file
@@ -0,0 +1,7 @@
|
||||
```sql
|
||||
select `pg_terminate_backend(pid)` from `pg_stat_activity` where `datname`='testdb' and `pid`<>`pg_backend_pid();`
|
||||
```
|
||||
==上面sql表示的是关闭数据库testdb的活动连接,接下来就可以用==
|
||||
```sql
|
||||
drop database `testdb;`
|
||||
```
|
||||
@@ -0,0 +1 @@
|
||||
systemctl start postgresql-12.service // 启动服务systemctl stop postgresql-12.service // 关闭服务systemctl restart postgresql-12.service // 重启服务systemctl status postgresql-12.service // 查看状态
|
||||
7
数据库/PostgreSQL/PostgreSQL删除数据库.md
Executable file
7
数据库/PostgreSQL/PostgreSQL删除数据库.md
Executable file
@@ -0,0 +1,7 @@
|
||||
```sql
|
||||
select `pg_terminate_backend(pid)` from `pg_stat_activity` where `datname`='testdb' and `pid`<>`pg_backend_pid();`
|
||||
```
|
||||
==上面sql表示的是关闭数据库testdb的活动连接,接下来就可以用==
|
||||
```sql
|
||||
drop database `testdb;`
|
||||
```
|
||||
18
数据库/PostgreSQL/PostgreSQL安装.md
Executable file
18
数据库/PostgreSQL/PostgreSQL安装.md
Executable 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/)>
|
||||
4
数据库/PostgreSQL/PostgreSQL密码修改.md
Executable file
4
数据库/PostgreSQL/PostgreSQL密码修改.md
Executable 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';
|
||||
Reference in New Issue
Block a user