/etc/postgresql/9.x/main/
//open file named postgresql.conf
vi postgresql.conf
//add this line to that file
listen_addresses = ‘*’
//then open file named pg_hba.conf
sudo vi pg_hba.conf
//and add this line to that file
host all all 0.0.0.0/0 md5
//It allows access to all databases for all users with an encrypted password
//restart your server
sudo /etc/init.d/postgresql restart
来自 https://stackoverflow.com/questions/32439167/psql-could-not-connect-to-server-connection-refused-error-when-connecting-to
What If I forgot my Postgres user password?
If you forgot your postgres password, you can login without
password by changing “md5” to “trust” in pg_hba.conf file and restart the
PostgreSQL server.
After login, you can ALTER
postgres user:
ALTER USER postgres PASSWORD ‘MyNewPassword’;
Now again change your pg_hba.conf entry from “trust” to “md5”
and restart the PostgreSQL server.
来自 https://www.dbrnd.com/2016/08/postgresql-password-authentication-failed-for-user-postgres-in-ubuntu-reset-forgot-postgres-super-user-password/
PostgreSQL failed to start, could not create lock file: permission denied
Check owner of /var/run/postgresql and set it to postgres if not already so To do , type
sudo chown -R postgres:postgres /var/run/postgresql
If user you are running as does not have sudo privilege, then
1) Change to root
su -
2) Change ownership of /var/run/postgresql to postgres user and postgres group
chown -R postgres:postgres /var/run/postgresql
I had the same problem when installing postgres on Ubuntu 14.04 and changing the ownership fixed the problem for me.
来自 https://stackoverflow.com/questions/22851352/postgresql-server-failed-to-start-could-not-create-lock-file-permission-denied
Try it manually with debug enabled. This will cause it to run in the
foreground and print any error messages to standard error, while also
increasing the verbosity.
I believe this will be the correct command line for PostgreSQL 9.3 on Ubuntu, but
it might require some very slight tweaking (note: line is split for
readability; you can recombine it to a single line (without the backslash) if
you want):
/usr/lib/postgresql/9.3/bin/postgres -d 3 -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf
The beginning is the location of the postgres binary, then we enable
debug and set it to level 3 (you can adjust this up or down to increase or
decrease verbosity). Next we specify the data directory and the config file to
start with. These should be the defaults for Ubuntu Server 12.04, I think.
来自 https://serverfault.com/questions/587239/postgres-server-fails-to-start-produces-no-log-how-to-to-troubleshoot
First: If your install isn’t already damaged, you can drop unwanted PostgreSQL servers (“clusters”) in Ubuntu using pg_dropcluster. Use that in
preference to a full purge and reinstall if you just want to start with a freshly initdb’d PostgreSQL instance.
If you really need to do a full purge and reinstall, first make sure PostgreSQL isn’t running. ps -C postgres should show no results.
Now run:
apt-get –purge remove postgresql*
to remove everything PostgreSQL from your system. Just purging the postgres package isn’t enough since it’s just an empty meta-package.
Once all PostgreSQL packages have been removed, run:
rm -r /etc/postgresql/
rm -r /etc/postgresql-common/
rm -r /var/lib/postgresql/
userdel -r postgres
groupdel postgres
You should now be able to:
apt-get install postgresql
or for a complete install:
apt-get install postgresql-8.4 postgresql-contrib-8.4 postgresql-doc-8.4
来自 https://stackoverflow.com/questions/2748607/how-to-thoroughly-purge-and-reinstall-postgresql-on-ubuntu
You will find initdb under /usr/lib/postgresql/x.y/bin/. See also /usr/share/doc/postgresql-common/README.Debian.gz for more information on the
setup on Debian and Ubuntu.
来自 https://askubuntu.com/questions/371737/install-postgresql-why-is-initdb-unavailable/371838#371838?newreg=d586c2f2354540d0b88de93b8b11d756
initdb is the underlying command but Debian and Ubuntu users should be using pg_createcluster and its related suite of commands. Furthermore
you normally do not need to initdb OR pg_createcluster after apt-get install postgresql because
the standard install already creates a default cluster, with a server and default/template databases, for you. The README Peter mentions above is worth
your time to read
来自 https://askubuntu.com/questions/371737/install-postgresql-why-is-initdb-unavailable/371838#371838?newreg=d586c2f2354540d0b88de93b8b11d756
pg_restore: WARNING: no privileges could be revoked for “public”
Provide superuser role to your postgres user,
postgres=# alter role superuser;
来自 https://stackoverflow.com/questions/43142532/pg-restore-works-correctly-but-with-some-errors