Operating system: Ubuntu
Run the following command to create a database named mydb
createdb mydb
Get an error: PSQL: fatal: role “Terry” does not exist. Terry is my machine name. There is no role named Terry in the PostgreSQL database, so this error will be reported. Just add the – U parameter to specify an existing role, so I change the above command to:
createdb mydb -U postgres
Get another error: PSQL: fatal: Peer authentication failed for user “Postgres”. The solution is as follows:
1. Run the following command to edit PG_ Hba.conf file
sudo gedit /etc/postgresql/9.1/main/pg_hba.conf
2. Will
# Database administrative login by Unix domain socket local all postgres peer
Change to
# Database administrative login by Unix domain socket local all postgres trust
3. After saving, execute the following command to reload the configuration file:
sudo /etc/init.d/postgresql reload
Then execute CREATEDB mydb1 – u Postgres, and the mydb1 database has been successfully created
Similar Posts:
- [Solved] psql: 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”?
- PostgreSQL Connect Error: FATAL: no pg_hba.conf entry for host
- [How to Solve] psql: FATAL: role “postgres” does not exist
- error: permission denied to create database [How to Solve]
- [Solved] PSQL: fatal: the database system is starting up
- 029.PGSQL-pgsql Create New User Login Error: psql: FATAL: role “pguser” is not permitted to log in
- An error prompt appears during the installation of win10 PostgreSQL: “failed to load SQL modules into the database cluster”
- [Solved] k8s Deploy postgresql Error: initdb: error: directory “/var/lib/postgresql/data” exists but is not empty
- The use of libpqxx interface in Linux solves the error of PSQL: connections on UNIX domain socket “/TMP/.S.pgsql.5432”
- [Solved] zabbix Monitor postgres Error: “sh:psql command not found”