code_test/postgresql安装错误.txt
2024-10-04 13:00:10 +08:00

41 lines
1.1 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

  问题sudo service postgresql start 启动后 发现连不上数据库psql 和msfconsole都提示:
could not connect to database template1: could not connect to server: No such file or directory.
Is the server running locally and accepting
connections on Unix domain socket "var/run/postgresql/.s.PGSQL.5432"?
发现并没有监听默认5432端口。
多次尝试后发现,并没有初始化数据库,现记录下初始化并启动过程(postgresql安装完毕):
1.给数据库的postgres用户设置密码:
$ sudo passwd postgres
2.创建postgresql的data文件夹
$ sudo mkdir /data
$ sudo chmod o+w /data
$ su - postgres
$ mkdir /data/postgresql
$ mkdir /data/postgresql/data
3.postgres用户初始化数据库
$ /usr/lib/postgresql/12/bin/initdb -D /data/postgresql/data
初始化看到几个OK之后最后Success然后提示启动数据库命令:pg_ctl ...
4.postgres用户启动数据库
/usr/lib/postgresql/12/bin/pg_ctl -D /data/postgresql/data -l logfile start
waiting for server to start .... done
server started
5.检查是否监听端口
$ ss -ant