PostgreSQL is a powerful object-relational database management system, provided under a flexible BSD-style license. PostgreSQL contains many advanced features, is very fast and standards compliant.
PostgreSQL or Postgres is a powerful high-performance object-relational database management system (ORDBMS) released under a flexible BSD-style license. PostgreSQL is well suited for large databases and has many advanced features.
PostgreSQL is available for many operating systems including Linux, FreeBSD, Solaris, and Microsoft Windows.
PostgreSQL has bindings for many programming languages such as C, C++, Python, Java, PHP, Ruby and now it’s possible to develop ASP.net Core C# Web Applicaitons using Entity Framework Core to make use of Postgres databases. It can be used to power anything from simple web applications to massive databases with millions of records.
In this post I will provide instructions on how to install Postgres on a ubuntu 16.04 laptop to enable development of ASP.net core applications using Postgres SQL backend databases.
Installation of Postgres SQL
The Ubuntu Documentation also provides instructions on how to install Postgres SQL . However I will provide some quick start installations that I use to get my laptop ready for development.
This will install the latest version available in your Ubuntu release and the commonly used add-ons for it.
postgresql – core PostgreSQL engine and RDBMS around which everything else is build. The core files for this database server is installed in this package.
postgresql-contrib – additional packages that are provided by the team to work with database server.
pgadmin3 – a comprehensive PostgreSQL database design and management system for *nix and Windows systems. It is freely available under the terms of the Artistic Licence and may be redistributed provided the terms of the licence are adhered to.
Connect to Postgres SQL
After installing PostgreSQL database server, by default it creates a user
postgres with role
postgres. It also creates a system account with same name
postgres. So to connect to postgres server, login to your system as user postgres and connect database.
To start off, we need to set the password of the PostgreSQL user (role) called “postgres”; we will not be able to access the server externally otherwise. As the local “postgres” Linux user, we are allowed to connect and manipulate the server using the psql command.
this connects as a role with same name as the local user, i.e. “postgres”, to the database called “postgres” (1st argument to psql).
Set a password for the “postgres” database role using the command:
and give your password when prompted. The password text will be hidden from the console for security purposes.
To exit use either [key]Ctrl[/key] + [key]D[/key] or [key][/key] + [key]q[/key] at posgreSQL prompt.
Once login is confirmed we can then check login info using following command from database command prompt.
If you see details similar to the above then your Postgres SQL has been installed successfully.
Create your account
For development purposes you probably don’t want or need to allow for other machines or user accounts to access your Postgres Database. So you may only want to allow access to your databases via your logged on user account.
Client programs, by default, connect to the local host using your Ubuntu login name and expect to find a database with that name too. So to make things REALLY easy, use your new superuser privileges granted above to create a database with the same name as your login name:
You can now
exit to get back to terminal
Pg Admin console
pgadmin3 console from the terminal
This should start the application and you should be presented with the management screen
You can now connect to your instance by clicking on the plug icon and entering a name and the username and password.