You will be prompted for the postgres user's administrative password that you set during the PostgreSQL configuration process:. Installation methods differ depending on the Linux distribution you are using. Follow the section below that matches your Linux distribution. You can either choose to use the version of PostgreSQL available in your distribution's default repositories or use repositories provided by the PostgreSQL project.
Packages in the default repository are tested to work with all other software provided for your distribution, but may be older. Packages from the PostgreSQL project will be more up-to-date but may require extra configuration. To install PostgreSQL server, update your computer's local package cache with the latest set of packages.
Afterwards, install the postgresql package:. By default, PostgreSQL is configured to use peer authentication , which allows users to log in if their operating system user name matches a PostgreSQL internal name.
The installation process created an operating system user called postgres to match the postgres database administrative account. To log into PostgreSQL with the psql client, use sudo to run the command as the postgres user:. When you are finished, you can exit the psql session by typing:.
If you need a more up-to-date version of PostgreSQL, you can use the repositories maintained by the PostgreSQL project instead of those provided by your Linux distribution. Next, add the PostgreSQL package signing key to apt so that it trusts the packages in the new repository:. With the repository set up, you can update your local package index and then install PostgreSQL by typing:. What exactly is happening? It's normally locked from the OS.
No one is supposed to "log in" to the operating system as postgres. You're supposed to have root to get to authenticate as postgres. It's normally not password protected and delegates to the host operating system. This is a good thing. And, that means that you could normally wreck havoc anyway. By keeping this disabled, you remove the risk of a brute force attack through a named super-user.
Concealing and obscuring the name of the superuser has advantages. Evan Carroll Evan Carroll With the first method, the user ends up with no privileges. FabienSnauwaert the -s makes the user a superuser. This worked for me in the standard Ubuntu Robert Robert I downvoted because I think activating the postgres user is a bad idea. If you're running macOS like I am, you may not have the postgres user.
When trying to run sudo -u postgres psql I was getting the error sudo: unknown user: postgres Luckily there are executables that postgres provides. Nick Woodhams Nick Woodhams LifeInstructor 1, 1 1 gold badge 18 18 silver badges 24 24 bronze badges. Suman Astani Suman Astani 1, 11 11 silver badges 16 16 bronze badges. In MacOS, I followed the below steps to make it work. For the first time, after installation, get the username of the system. SuperNova SuperNova Neall Neall For RHEL6. Change ident to trust for host and local if you are using ssh.
This was the default behavior up to PostgreSQL 9. The new user will be allowed to log in that is, the user name can be used as the initial session user identifier. The new user will not be allowed to log in. A role without login privilege is still useful as a means of managing database permissions.
If given, createuser will issue a prompt for the password of the new user. This is not necessary if you do not plan on using password authentication. Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections.
Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a. Refer to Chapter 17 and Chapter 19 for information about managing users and authentication. You must be a database superuser to use this command. This is normally not necessary, but may be useful if you need to recreate the owner of an orphaned object. If this is not specified, the highest assigned user ID plus one with a minimum of will be used as default.
These clauses define a user's ability to create databases.
0コメント