Postgresql 10 install linux mint

How To Install PostgreSQL 10 on Linux Mint 18.3

The PostgreSQL Development Team has announced the latest version PostgreSQL 10. PostgreSQL is an open source object-relational database system. It is one of leading database server used for production servers. PostgreSQL allows us to execute stored procedures in various programming languages, like C/C++, Python, Java, Perl, Ruby and its own PL/pgSQL, which is similar to Oracle’ s PL/SQL. The method to install PostgreSQL on Linux Mint 18.3 is covered in this tutorial.

First create a file at source list /etc/apt/sources.list.d/postgresql.list .

linuxhelp ~ # sh -c ' echo " deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" > /etc/apt/sources.list.d/pgdg.list' Import repository key: linuxhelp ~ # wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - OK

And then update the system repository.

linuxhelp ~ # apt-get update Hit:1 http://archive.canonical.com/ubuntu xenial InRelease Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease Ign:3 http://packages.linuxmint.com sylvia InRelease Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB] Get:5 http://packages.linuxmint.com sylvia Release [24.2 kB] Get:6 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB] Get:7 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease [46.4 kB . . Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [592 kB] Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [547 kB] Get:25 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [239 kB] Fetched 5,464 kB in 11s (464 kB/s) Reading package lists. Done

Now we have to Install PostgreSQL 10

linuxhelp ~ # apt-get install postgresql-10 Reading package lists. Done Building dependency tree Reading state information. Done The following additional packages will be installed: libpq5 pgdg-keyring postgresql-client-10 postgresql-client-common postgresql-common Suggested packages: locales-all postgresql-doc-10 libjson-perl Recommended packages: sysstat The following NEW packages will be installed: libpq5 pgdg-keyring postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common . . Ver Cluster Port Status Owner Data directory Log file 10 main 5432 down postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log update-alternatives: using /usr/share/postgresql/10/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode Processing triggers for libc-bin (2.23-0ubuntu9) . Processing triggers for systemd (229-4ubuntu21) . Processing triggers for ureadahead (0.100.0-19) .

Next, we have to change postgres user password by login to postgres user.

linuxhelp ~ # su &ndash postgres

Now get into psql database using the following command.

[email protected] ~ $ psql psql (10.2 (Ubuntu 10.2-1.pgdg16.04+1)) Type " help" for help. postgres=# Run the following command to alter password postgres=# ALTER USER postgres WITH PASSWORD ' somepassword' ALTER ROLE replace the ‘ somepassword’ with your preferred password and then exit postgres=# q [email protected] ~ $ exit logout

Now let’ s try installing postgresql GUI client &ndash pgadmin3 by running the following command.

linuxhelp ~ # apt-get install pgadmin3 Reading package lists. Done Building dependency tree Reading state information. Done The following additional packages will be installed: libjs-jquery libjs-underscore libwxbase3.0-0v5 libwxgtk3.0-0v5 pgadmin3-data Suggested packages: javascript-common postgresql-contrib Recommended packages: javascript-common pgagent The following NEW packages will be installed: . . Setting up libjs-underscore (1.7.0~dfsg-1ubuntu1) . Setting up libwxbase3.0-0v5:amd64 (3.0.2+dfsg-1.3ubuntu0.1) . Setting up libwxgtk3.0-0v5:amd64 (3.0.2+dfsg-1.3ubuntu0.1) . Setting up pgadmin3-data (1.22.2-4.pgdg16.04+1) . Setting up pgadmin3 (1.22.2-4.pgdg16.04+1) . Processing triggers for libc-bin (2.23-0ubuntu9) .

Now the PostgreSQL installation along with pgadmin3 has been completely installed. with this, the method to install Postgresql 10 on Linux Mint 18.3 comes to an end

Читайте также:  Mounting rootfs in linux

Источник

How to Install PostgreSQL 10 on Linux Mint 18.3 Sylvia

how-to-install-postgresql-10-on-linux-mint-18-3-sylvia

The installation process for Postgres on Ubuntu or Linux Mint is, like a lot of things in the Linux world, less than intuitive for new users. As much for my own benefit as anyone else’s, now I am going to walk through the steps to getting Postgres installed and configured on a Linux box.

Note: if you are an experienced Linux user, or a PostgreSQL DBA, this is not the post for you, even though your remarks and constructive criticism are very welcome – in case you see something either incorrect or missing, please do let me know inside the comments below.

So why Postgres?

PostgreSQL is a amazing database platform. PostgreSQL is free, cross-platform, and gives an high-quality function set which, in my mind, exceeds the ones of its similar platform in the relational database area.

PostgreSQL offers all of the (mostly) standard-compliant SQL/relational database function you’ll anticipate, plus a bunch of thrilling and innovative features. Some of worth mentioning features are json datatype (and additionally jsonb!), array datatype, and the brand new HStore type, which essentially allows the specification of a column as containing a list of key/value pairs. We’ll take a tour of PostgreSQL in every other posts, but first, let’s get the thing installed and running.

Installation steps for PostgreSQL on Linux Mint

Currently, my everyday Linux distro is Linux Mint 18.3 Sylvia along with the Cinnamon Desktop. This is a stable release and could be a fantastic distro if you haven’t use Linux already. If you do not have a dedicated Linux machine, it is simple enough to spin up a VM using Virtual Box.

As of this writing, the most up-to-date version of PostgreSQL is version 10.4, which introduced with it very cool features such as full JSONB support. However, the 10.4 release is not available directly using the Advanced Packaging Tool (APT) or the Linux Mint Software Manager.

Читайте также:  Linux mint software update

Fortunately, the PostgreSQL Global Development Group (PGDG) maintain an apt repository of PostgreSQL packages for Debian and Ubuntu-derived Linux distros, located at http://apt.postgresql.org/pub/repos/apt/

Before we can install PostgreSQL, we have to add the package source for the distro we are currently using. In this case, I have been using Linux Mint 18.3 Sylvia, which is derived from (and therefore should be compatible with) Ubuntu 16.04 («Xenial Xerus») release. We’ll understand why this matters in a short while.

What’s currently supported:

  • Debian 7 (wheezy), 8 (jessie), 9 (stretch), and unstable (sid)
  • Ubuntu 14.04 (trusty), 16.04 (xenial)
  • Architectures: amd64 (64-bit x86), i386 (32-bit x86), ppc64el (little-endian 64-bit POWER; not on wheezy/precise)
  • PostgreSQL 9.2, 9.3, 9.4, 9.5, 9.6, 10, 11devel
  • Server extensions such as Slony-I, various PL languages, and datatypes
  • Applications like pgadmin3, pgbouncer, and pgpool-II
  • Debian 7 (wheezy), 8 (jessie), 9 (stretch), and unstable (sid)

Add the PostgreSQL Package Source for Your Linux Distribution

We need to create a sources file reflecting the proper PostgreSQL source for our specific distro. As noted above, in my case I’ll need the source appropriate for the «Xenial» release of Ubuntu. We can accomplish this from the terminal to add the file (make sure to use sudo in all of the following steps):

Add the PGDG APT source file

Create a file at /etc/apt/sources.list.d/postgresql.list with the following command:
$ sudo sh -c ‘echo «deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main» > \
/etc/apt/sources.list.d/postgresql.list’

Add the PostgreSQL Package Repository Key

Next, add the package repository key:

$ wget —quiet -O — https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add —

Update, Upgrade, and Install PostgreSQL

Update system package source. Once this task is done, we proceed with upgrade packages to the latest versions.

$ sudo apt-get update
$ sudo apt-get upgrade

Please note that this can be a long process. Also, you may be prompted at several points to make some choices about configuration items. Specifically, you may informed that this that or the other configuration file has been changed, and asked if you want to keep your original version, or replace with the package maintainer’s version. Select «Y» to accept the package maintainer’s version in these cases.

Next step is installing PostgreSQL 10:

$ sudo apt-get install postgresql-10

Configuring Postgres for Use

The postgres user

While PostgreSQL become installed, a system user account named postgres was also created with an identical user account in postgres. By default, the postgres user account isn’t configured with a password, so it isn’t viable to log into the server the use of the postgres user account without first creating a password for it. This postgres account has an all-access pass on your PostgreSQL database server, permission-wise. The postgres user account has similarities to the sa account in SQL server.

Читайте также:  Linux снять атрибут только чтение

The postgres database

PostgreSQL is installed with a default database postgres . For the most part, we use the postgres database for administration functions, and create new databases on the PostgreSQL server to suit our needs.

The psql Command Line Utility

PostgreSQL consists of psql , a command line application for managing your databases and server. While a GUI-based software such as pgadmin3 is often less complicated to use in the daily task, the command line utilty psql is always handy. psql gives total control of your postgres system from the terminal, together with the ability to execute SQL queries.

We will use psql to perform our preliminary configuration and to create an initial database super user.

Create super user account

In this step we will super-user account to deals with our database in the daily task.

To do this, we will get access to the postgres account through your machine root user. Then we’ll use that postgres account to create a brand new super-user account for your PostgreSQL installation which can be regulated more efficiently. As an example we will use adjie as our new PostgreSQL super-user account.

$ sudo su - 
[sudo] password for adjie:
# su - postgres
$ psql
postgres=# CREATE USER adjie postgres-# WITH SUPERUSER CREATEDB CREATEROLE postgres-# PASSWORD 'your-preferred-password';

Notice in the above we can enter multiple lines of command in SQL shell. The SQL is not executed until semi-colon followed enter is found. Which means, the semi-colon will make the shell execute entered commands.

Login using our newly created account

Let’s verify that everything is working correctly. Try to log in with psql using our new super-user account and create a quick test database:

$ psql postgres
psql (10.4 (Ubuntu 10.4-2.pgdg16.04+1))
Type "help" for help.

postgres=#

Note in the above terminal session, we specified the postgres default database when we logged in, since there aren’ tyet any other databases to connect to.

Create test database

Next test is to create test database test_database using our new super-user account:

postgres=# CREATE DATABASE test_database WITH OWNER adjie;
CREATE DATABASE
postgres=# \connect test_database;
You are now connected to database "test_database" as user "adjie".
test_database=#

If everything works as shown, then congratulations. Now you have a working installation of PostgreSQL 10.4 on Linux Mint 18.3.

Optional step

If you would like to manipulate your database in graphical mode, then pgadmin3 is the way to go. Install pgadmin3 by issuing this command:

$ sudo apt-get install pgadmin3

Final Words

I hope that you now know how to install PostgreSQL 10.4 on Linux Mint 18.3 Sylvia. If you run into any issues or have any feedback feel free to drop a comment below.

Источник

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