Postgresql установка linux manjaro

How to setup PostgreSQL and PGAdmin on Manjaro Linux / Arch

This guide is here just because I’ve messed up the installs on arch before, and turns out it’s actually pretty easy to do.

Step 1 — Install the dependencies

sudo pacman -S yay yay postgresql pgadmin4 

Step 2 — Setup postgres service

sudo -u postgres -i # login as postgres initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data/' exit sudo systemctl enable --now postgresql sudo systemctl status postgresql # to check for any errors 

Step 3 — Setup password

psql -U postgres postgres=# \password # to set password 

Step 4 — Setup connection security

$ su # cd /var/lib/postgres/data # cp pg_hba.conf pg_hba.conf.backup # in case you mess up # nano pg_hba.conf 
 TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust # Allow replication connections from localhost, by a user with the # replication privilege. local replication all trust host replication all 127.0.0.1/32 trust host replication all ::1/128 trust 

«Method» is set to trust, meaning it won’t ask for the password to anyone. To fix that, change the method from trust to md5 everywhere. And that should be it for postgres!

Bonus: shortcuts

> psql dbname postgres # to directly open a database postgres=# \c # see current database postgres=# \l # see list of databases postgres=# \c dbname # set database postgres=# create database dbname; # create database postgres=# \dt # see list of tables 

Step 6 — PgAdmin

Host: localhost Port: 5432 Maintenance database: postgres Username: postgres Password:

Top comments (7)

One more info: Sometimes, do you need to install postgis package:

This is required when you not found the initdb application.

3 likes Like Comment button

I didn’t know that! Thanks for letting me know.

1 like Like Comment button

I just followed the steps and PgAdmin not working and saw this error on my terminal.

QCoreApplication::applicationFilePath: Please instantiate the QApplication object first
QCoreApplication::applicationFilePath: Please instantiate the QApplication object first
Semaphore name: «pgadmin4—sema»
Shared memory segment name: «pgadmin4-sha888—shmem»
Python path: «/usr/lib/python3.10:/usr/lib/python3.10/lib-dynload:/usr/lib/python3.10/site-packages»
Python Home: «/usr/lib/python3.10»
Webapp path: «/usr/lib/pgadmin4/web/pgAdmin4.py»

How to solve this?
Thanks in advance.

1 like Like Comment button

Currently interested in TypeScript, Vue, Kotlin and Python. Looking forward to learning DevOps, though.

Manjaro won’t let me install pgadmin4-5.1 . It is breaking the promise of always up-to-date?

1 like Like Comment button

Источник

How To Install PostgreSQL on Manjaro 20

In this tutorial, we will show you how to install PostgreSQL on Manjaro 20. For those of you who didn’t know, PostgreSQL is a relational database management system that provides an implementation of the SQL querying language. It’s standards-compliant and has many advanced features like reliable transactions and concurrency without reading locks.

Читайте также:  Ide java linux mint

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘ sudo ‘ to the commands to get root privileges. I will show you through the step-by-step installation of PostgreSQL on a Manjaro 20 ( Nibia ).

Prerequisites

  • A server running one of the following operating systems: Manjaro 20.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user . We recommend acting as a non-root sudo user , however, as you can harm your system if you’re not careful when acting as the root.

Install PostgreSQL on Manjaro 20 Nibia

Step 1. Before running the tutorial below, make sure that our system is up to date:

sudo pacman -Syu sudo pacman -S git

Step 2. Installing PostgreSQL on Manjaro 20.

Now we run the following command below to install PostgreSQL:

sudo pacman -S postgresql postgis

After the installation finishes, continue with the following command:

sudo su postgres -l # or sudo -u postgres -i initdb --locale $LANG -E UTF8 -D '/var/lib/postgres/data/' exit

By default, the PostgreSQL service is started automatically after the installation. You can confirm if it is running with the command:

sudo systemctl status postgresql

You can check PostgreSQL’s version with:

Step 3. Installing PgAdmin on Manjaro.

PgAdmin is a web-based PostgreSQL management console. Now run the following command to install PgAdmin on the Manjaro system:

Step 4. Accessing the PostgreSQL command prompt.

Once installing the PostgreSQL database server, by default, it creates a user ‘ postgres ’ with role ‘ postgres ’. It also creates a system account with the same name ‘ postgres ’. So to connect to the Postgres server, log in to your system as a user of Postgres and connect database:

Create a new user and database:

### For example, let us create a new user called “meilana” with password “maria”, and database called “meilanadb”. ### sudo -u postgres createuser -D -A -P meilana sudo -u postgres createdb -O maria meilanadb

Congratulations! You have successfully installed PostgreSQL. Thanks for using this tutorial for installing the latest version of PostgreSQL on the Manjaro system. For additional help or useful information, we recommend you check the official PostgreSQL website.

If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Источник

How To Install PostgreSQL on Manjaro 21

In this tutorial, we will show you how to install PostgreSQL on Manjaro 21. For those of you who didn’t know, PostgreSQL (often called Postgres) is a free, open-source, and advanced relational database management system and is developed by The PostgreSQL Global Development Group. Users may rely on the PostgreSQL database system for its dependability, data integrity, extensive feature set, and flexibility.

Читайте также:  Linux под процессор arm

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘ sudo ‘ to the commands to get root privileges. I will show you the step-by-step installation of the PostgreSQL open-source relational database management system on a Manjaro 21 (Ornara).

Prerequisites

  • A server or desktop running one of the following operating systems: Manjaro or Arch Linux.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user . We recommend acting as a non-root sudo user , however, as you can harm your system if you’re not careful when acting as the root.

Install PostgreSQL on Manjaro 21

Step 1. Before running the tutorial below, make sure that our system is up to date:

sudo pacman -Syu sudo pacman -S base-devel

Step 2. Installing PostgreSQL on Manjaro 21.

By default, PostgreSQL is available on the Manjaro 21 base repository. You can install PostgreSQL easily on Manjaro, just need to run the following command below:

sudo pacman -S postgresql php php-pgsql

After successfully installed, now we make PHP work with PostgreSQL, we have to enable it in php.ini :

Uncomment the following lines:

extension=pdo_pgsql extension=pgsql

Save and close the file, then restart Apache or your installed web server application to take change effect:

sudo systemctl restart httpd

Step 4. PostgreSQL Initial Setup.

Now we need to setup the database server so we can use it anywhere we would like to:

sudo systemctl start postgresql

If a got an error “related to initdb : data folder does exist”. Now login to PostgreSQL as postgres user:

Next, run the following command:

initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data' exit

After that, try to start PostgreSQL again:

sudo systemctl start postgresql sudo systemctl enable postgresql

Step 5. Create Users and Databases.

To create a database, connect to PostgreSQL. A default user named ‘postgres‘ is established when PostgreSQL is installed. Connect to this user first. We will create a database called idrootdb .

Create a user with createuser a tool and -P flag to set a password. pguser is the username:

Create a database with createdb a tool. idrootdb is the database name:

Once done, we will assign pguser to idrootdb in psql shell:

Next, run the following command to grant all the privileges to the user pguser on idrootdb database:

GRANT ALL PRIVILEGES ON DATABASE idrootdb TO pguser;

If you want that pguser should be able to create databases too (for example using a PHP script or any other tool). Run this command to alter pguser and give permission of creating databases. Quit with \q :

ALTER USER pguser CREATEDB; \q

Congratulations! You have successfully installed PostgreSQL. Thanks for using this tutorial for installing the latest version of PostgreSQL open-source relational database management system on the Manjaro system. For additional help or useful information, we recommend you check the official PostgreSQL website.

Читайте также:  Linux опции монтирования fstab

If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Источник

marcorichetta / postgresql-manjaro.md

You should now be in a shell session for the postgres user. Log into a Postgres session by typing:

First, we will create a database for our Django project. Each project should have its own isolated database for security reasons. We will call our database myproject in this guide, but it’s always better to select something more descriptive:

CREATE DATABASE myproject;

Next, we will create a database user which we will use to connect to and interact with the database. Set the password to something strong and secure:

CREATE USER myprojectuser WITH PASSWORD ‘password’;

Afterwards, we’ll modify a few of the connection parameters for the user we just created. This will speed up database operations so that the correct values do not have to be queried and set each time a connection is established.

We are setting the default encoding to UTF-8, which Django expects. We are also setting the default transaction isolation scheme to “read committed”, which blocks reads from uncommitted transactions. Lastly, we are setting the timezone. By default, our Django projects will be set to use UTC:

ALTER ROLE myprojectuser SET client_encoding TO 'utf8'; ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed'; ALTER ROLE myprojectuser SET timezone TO 'UTC';

Now, all we need to do is give our database user access rights to the database we created:

GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;

Exit the SQL prompt to get back to the postgres user’s shell session:

Exit out of the postgres user’s shell session to get back to your regular user’s shell session:

Install the package to connect to our DB through Django

pip install django psycopg2

On settings.py we need to change the driver and configure the credentials to connect to our PostgreSQL DB:

DATABASES = < 'default': < 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'myproject', 'USER': 'myprojectuser', 'PASSWORD': 'password', 'HOST': 'localhost', 'PORT': '', > >

For testing, Django will try to create a test database with the USER set in settings.py (in this case myprojectuser)

In this case you need to give permission to create databases to that user.

# Log as postgres user and execute psql sudo su - postgres psql \du # List all roles with his permissions ALTER USER myprojectuser CREATEDB # Also can be used with ALTER ROLE (See Postgres docs) \du # Should list the new permission \q exit

Источник

Оцените статью
Adblock
detector