After entering the password, you’ll be at the PostgreSQL prompt for the ‘mydb’ database.Ĭongratulations! You’ve created your first PostgreSQL on Ubuntu database and user as well as successfully installed PostgreSQL on Ubuntu 22.04. You’ll be prompted to enter the password for ‘myuser’. Then, type the following command: psql -d mydb -U myuser To access the new database with the new role, first exit the ‘postgres’ user shell by typing ‘exit’ and hitting enter. Let’s start by making a new database called “mydb.” Use the following command: createdb mydb Step 7: Accessing the New Database With the ‘createdb’ command, you can create new databases just like you can create new roles from the command line. It’s safer to reply “no” for security reasons unless you specifically require superuser privileges for this role. You will then be prompted to choose whether the new role should be a superuser. You will be prompted by the system to enter a password and the name of the new role (we’ll use “myuser”). then enter the command as follows: createuser -interactive -pwprompt First, hit enter after typing “q” to end the PostgreSQL prompt. ‘Myuser’ will be the name of our new role. With the ‘createuser’ command in PostgreSQL, you can create new roles directly from the command line. You’ll now be at the PostgreSQL prompt, where you can issue SQL commands. Then, to access the PostgreSQL prompt, type: psql Type the following command to sign in as the ‘postgres’ user: sudo su - postgres As a superuser, the ‘postgres’ user has full administrative authority. PostgreSQL employs a role-based authentication system by default. The output should indicate that the PostgreSQL service is active (running) if PostgreSQL is functioning properly. Enter the command below into the terminal: sudo systemctl status postgresql We can check PostgreSQL’s service status to make sure the installation went smoothly. PostgreSQL will automatically create a new user account called “postgres” and a new database also called “postgres”. Using this command, PostgreSQL and some additional tools will be installed. Enter the following command in the terminal: sudo apt install postgresql postgresql-contrib -y Now that the system packages have been updated, we can install PostgreSQL. This command will update and upgrade all the packages and applications installed on your Ubuntu system. Open the terminal and type the following command: sudo apt update & sudo apt upgrade -y You should have an internet connection to download the necessary packages.īefore we begin, we need to update the system’s default applications and packages.You should have access to a terminal/command line.You should have superuser (sudo) privileges.You should have Ubuntu 22.04 installed on your server.It also offers a range of features such as complex queries, foreign keys, triggers, updatable views, transactional integrity, and multiversion concurrency control.īefore we can install PostgreSQL on Ubuntu 22.04, there are a few prerequisites to check: PostgreSQL supports both SQL (relational) and JSON (non-relational) querying, making it a versatile choice for a variety of applications. This article provides a comprehensive guide on how to install PostgreSQL on Ubuntu 22.04.īefore we dive into the installation process, it’s important to understand what PostgreSQL is and why it’s a popular choice for many developers and organizations. It’s widely used for its robustness, advanced features, and powerful performance. PostgreSQL, also known as Postgres, is an open-source relational database management system (RDBMS) that emphasizes extensibility and SQL compliance. It will also show you how to create and manage your first PostgreSQL database. This tutorial will take you step-by-step through the installation of PostgreSQL on Ubuntu 22.04, explaining all necessary setup steps along the way.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |