Sixth, quit the psql by using the \q command: postgres=# \q Code language: Shell Session ( shell ) Third, unzip the dvdrental.zip file to get the dvdrental.tar file: $ unzip dvdrental.zip Code language: Shell Session ( shell )įourth, access the PostgreSQL using the psql tool: $ psql Code language: Shell Session ( shell )įifth, create the dvdrental database using the CREATE DATABASE statement: postgres=# create database dvdrental Code language: Shell Session ( shell ) Second, download the sample database using the curl tool: $ curl -O Code language: Shell Session ( shell ) You need to type the password of the current user and press the Enter keyboard. It’ll prompt you for the password of the current user. To load the sample database into the PostgreSQL database server, you follow these steps:įirst, switch over the postgres account using the following command: $ sudo -i -u postgres Code language: Shell Session ( shell ) To return to your regular system user, you execute the exit command like this: exit Code language: Shell Session ( shell ) Load the sample database This above command will bring you back to the postgres Linux command prompt. To quit the PostgreSQL prompt, you run the following command: postgres=# \q Code language: Shell Session ( shell ) You’ll access the postgres prompt like this: postgres=# Code language: Shell Session ( shell )įrom here, you can interact with the PostgreSQL like issuing a query. Then, you can access the PostgreSQL using the psql by typing the following command: $ psql Code language: Shell Session ( shell ) You need to provide the password and hit the Enter keyboard. It’ll prompt for the password of the current user. To connect to PostgreSQL using the postgres role, you switch over to the postgres account on your server by typing: $ sudo -i -u postgres Code language: Shell Session ( shell ) When you installed PostgreSQL, the installation process created a user account called postgres associated with the default postgres role. If a role exists in PostgreSQL, the same Linux user account with the same name is able to log in as that role. It means that PostgreSQL will associate its roles with the system accounts of Linux. By default, PostgreSQL uses ident authentication. In PostgreSQL, a user account is referred to as a role. Connect to the PostgreSQL database server via psql It will take few minutes to download and install the PostgreSQL. For example, to install PostgreSQL version 12, you use the following command: $ sudo apt-get install postgresql-12 Code language: Shell Session ( shell ) If you want to install a specific version, you can use postgresql-version instead of postgresql. Third, update the package list: $ sudo apt-get update Code language: Shell Session ( shell )įinally, install the latest version of PostgreSQL: $ sudo apt-get install postgresql Code language: Shell Session ( shell ) Second, import the repository signing key: $ wget -quiet -O - | sudo apt-key add - Code language: Shell Session ( shell ) You need to execute them one by oneįirst, execute the following command to create the file repository configuration: $ sudo sh -c 'echo "deb $(lsb_release -cs)-pgdg main" > /etc/apt//pgdg.list' Code language: Shell Session ( shell ) Once visiting the PostgreSQL download for Ubuntu page, you find the script that allows you to install PostgreSQL on Ubuntu. In this tutorial, we’ll show you how to install PostgreSQL on Ubuntu 20.04. To download and install PostgreSQL on Linux, you visit the download page and select your Linux distribution. It is recommended that you install PostgreSQL this way since it ensures a proper integration with the operating system including automatic patching and other update management functionality. Most Linux platforms such as Debian, Red Hat / CentOS, SUSE, and Ubuntu have PostgreSQL integrated with their package management. Summary: in this tutorial, you will learn how to download and install PostgreSQL on Linux.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |