Run the command psql -version to confirm your PostgreSQL version. Your version might be 9.5, 11 or 12 or any other version. Take note that 10 is the version of my PostgreSQL installation on my server. However, the PostgreSQL configuration directory in Ubuntu is located in /etc/postgresql/10/main. You can now locate the Postgres Database files by navigating the directory that was displayed. This should display an output similar to this: data_directory If you are successfully logged in, you will see a prompt similar to this: psql (11.5 (Ubuntu 11.5-3.pgdg18.04+1), server 10.10 (Ubuntu 10.10-1.pgdg18.04+1))Īt this point you will execute the query below to display the directory where Postgres Database files are stored on your Linux macchine: SHOW data_directory It will also request for the postgres password which you set up when you were setting up PostgreSQL on your machine. Confirm the PostgreSQL version you installed from the official repository by running the below command. sudo apt install -y postgresql postgresql-contrib postgresql-client. This can be accomplished by running the code below: psql Install PostgreSQL on Ubuntu by running the following command. Next, you will need to login into the psql terminal/prompt. It will request for the postgres user password which you set up when you were setting up PostgreSQL on your machine. Run the command below in your terminal to switch user to postgres user: su - postgres Template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +Īt this point you can create tables and use them.Here's how I located the directory of my Postgres database files in Ubuntu: Template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres + Postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 | Name | Owner | Encoding | Collate | Ctype | Access privileges You can list the databases to verify your creation: Output should be like sudo su - psql -d example Įnter the new value, or press ENTER for the default Next, to use your new user you have to create an equivalent linux user (root privilege are mandatory for this kind of command):Īdding new user `foo' (1001) with group `foo'. Postgres=# CREATE DATABASE example OWNER foo When you create a database you can set the owner: Postgres=# CREATE USER foo WITH PASSWORD 'bar' The first thing is to create a role (a sort of combination of users and rights in the PostgreSQL world): You must use the postgres default account and the psql CLI to create your new account (see before to remember how to connect to psql). To see how to use the command way, see the official documentation. In this tutorial we will only use the SQL way because it’s more exhaustive. There are two ways to add an user in PostgreSQL: with SQL queries or with a command in bash. Be careful when you use it, next chapters will explain you how to create standard users. Note that, by default, the installation of PostgreSQL creates a postgres account, this account is a super user account for the database. No VM guests are running outdated hypervisor (qemu) binaries on this host. No user sessions are running outdated binaries. Processing triggers for libc-bin (2.35-0ubuntu3). Processing triggers for man-db (2.10.2-1). Update-alternatives: using /usr/share/postgresql/14/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode Get:1 jammy/main amd64 libcommon-sense-perl amd64 3.75-2build1 Libcommon-sense-perl libjson-perl libjson-xs-perl libllvm14 libpq5 libsensors-config libsensors5 libtypes-serialiser-perl postgresql-14 postgresql-client-14Ġ upgraded, 14 newly installed, 0 to remove and 0 not upgraded.Īfter this operation, 161 MB of additional disk space will be used. The following NEW packages will be installed: Postgresql-client-common postgresql-common ssl-cert sysstat Libcommon-sense-perl libjson-perl libjson-xs-perl libllvm14 libpq5 libsensors-config libsensors5 libtypes-serialiser-perl postgresql-client-14 The following additional packages will be installed: To install PostgreSQL on Ubuntu, the easiest way is to use apt-get command: See the download section of the official documentation for older or newer versions. At the time of writing this tutorial, the last release of PostgreSQL is 14.x.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |