PostgreSQL is a database management system free under the license with the same name, which also has support for stored procedures in languages such as Java, C ++, Ruby, Python Perl ...
Deciding whether to use MySQL or PostgreSQL can be a dilemma. It seems that the first is somewhat faster than the second, but the second, being free, is much denser in terms of features. Therefore, in Ubunlog we want to teach you how Download, to install y prepare PostgreSQL for use in Ubuntu (or any other Linux distro) in the simplest way possible.
Installing PostgreSQL
To install it, we have to add a new repository to our list of repositories. We can do it easily by adding a line to our sources.list with the repository in question. For this we execute:
sudo sh -c 'echo «deb http://apt.postgresql.org/pub/repos/apt/` lsb_release -cs`-pgdg main »>> /etc/apt/sources.list.d/pgdg.list'
Now we have to download GPG key so that apt can check the validity of the packages that we download from the previous repository. We execute:
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
Now, we update the repositories:
sudo apt-get update
And to bring things to a close, we install the packages corresponding PostgreSQL:
sudo apt-get install postgresql postgresql-contrib
Prepare PostgreSQL for use
In order to start using PostgreSQL, we first have to connect us to your server. To do this, when installing PostgreSQL we have actually created a system user named "postgres". This user has PostgreSQL database administration privileges, so the first step is log in with that user:
sudo su - postgres
Now we have to start PostgreSQL terminal to log in to the database server. To do this we execute 'psql' and we we log to connect to the server.
psql
If we want to take a look at the connection or version that we have from PostgreSQL, we can execute the following command:
postgres- # \ conninfo
Finally, para disconnect from the server from the database, we can do it by executing the following:
postgres- # \ q
exit
Note that the command «exit» is executed to exit session that we had started at the beginning under the user «postgres».
If you have had any problems during the installation or preparation of PostgreSQL, please leave us in the comments section and we will do our best to help you. Until next time.
With the first command line I get the following
"Deb: 1:" deb: 'echo: not found
excellent bro