![]() ![]() Next, create the database using the createdb command: sudo su - postgres -c "createdb kylodb" In the following example, we’ll create a new role named kylo, a database named kylodb and grant privileges on the database to the role.įirst, create the role by issuing the following command: sudo su - postgres -c "createuser kylo" Only superusers and roles with CREATEROLE privilege can create new roles. ![]() The createuser command allows you to create new roles from the command line. The postgres user is typically used only from the localhost. You can use the sudo command to access the PostgreSQL prompt without switching users: sudo -u postgres psql To exit out of the PostgreSQL shell type: \q To log in to the PostgreSQL server as “ postgres”, switch to the user postgres and access a PostgreSQL prompt using the psql utility: sudo su - postgresįrom here you can interact with the PostgreSQL server. This user is the superuser for the PostgreSQL instance, and it is equivalent to the MySQL root user. The “ postgres” user is automatically created when PostgreSQL is installed. For local connections, PostgreSQL is set to use the peer authentication method. PostgreSQL client authentication is defined in the configuration file named pg_hba.conf. Peer – Same as Ident, but it is only supported on local connections.It works by obtaining the client’s operating system user name, with an optional user name mapping. Ident – Only supported for TCP/IP connections.The passwords can be stored as scram-sha-256 md5 and password (clear-text) Password – A role can connect by providing a password.Trust – A role can connect without a password, as long as the criteria defined in the pg_hba.conf are met.PostgreSQL supports several authentication methods. Depending on how you set up the role, it can represent a database PostgreSQL handles database access permissions using the concept of PostgreSQL Roles and Authentication Methods Psql is an interactive terminal program that allows you to interact with the PostgreSQL server. The output should look something like the following: PostgreSQL 11.5 (Debian 11.5-1+deb10u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit To verify the installation, use the psql tool to print the server version: sudo -u postgres psql -c "SELECT version() " Once the installation is complete, the PostgreSQL service will start. Install the PostgreSQL server and contrib package which provides additional features for the PostgreSQL database: sudo apt install postgresql postgresql-contrib To install PostgreSQL on your Debian server perform the following steps as root or user with sudo privileges: Enable Remote Access to the PostgreSQL ServerĪt the time of writing this article, the latest version of PostgreSQLĪvailable from the default Debian repositories is PostgreSQL version.PostgreSQL Roles and Authentication Methods. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |