

If you have a the error: psql: FATAL: Peer authentication failed for user "my_user" Note: You must specify a database (by default it will try connecting you to the database named the same as the user you are logged in as). To log in, from the terminal I use: psql -U ubuntu -d postgres You should call the PostgreSQL user the same as another existing user. You can connect directly to a database with the -d flag: psql -U my_user -d my_db To log in as another user, quit the prompt ( \q) and then use the command: psql -U my_user You can remove users with: DROP USER my_user Let’s add Superuser to it: ALTER USER my_user WITH SUPERUSER

If you run \du, you will see, however, that my_user has no attributes yet.
#Postgresql ubuntu password
To do so, use the command: CREATE USER my_user WITH PASSWORD 'my_password' It is recommended that you create another user (it is bad practice to use the default postgres user). Also, don’t forget the ( semicolumn) after every statement. Note: Replace postgres with the name of the user and my_password with the wanted password. You can change the password of any user (including postgres) with: ALTER USER postgres WITH PASSWORD 'my_password'
#Postgresql ubuntu install
Install PostgreSQL with the following commands: sudo apt update sudo sh -c 'echo "deb `lsb_release -cs`-pgdg main" > /etc/apt//pgdg.list'Įverything is ready now. If you are using Linux Mint, you’ll have to manually replace the `lsb_release -cs` the Ubuntu version your Mint release is based on. Now add the repository with the below command. Just follow these steps.Īdd the GPG key first: wget -quiet -O - | sudo apt-key add. To install PostgreSQL 11, you need to add the official PostgreSQL repository in your sources.list, add its certificate and then install it from there.ĭon’t worry, it’s not complicated. Method 2: Installing the latest version 11 of PostgreSQL in Ubuntu In most cases, it’s good to have the contrib package installed along with the PostgreSQL core.

The postgresql-contrib or the contrib package consists some additional utilities and functionalities that are not part of the core PostgreSQL package.
#Postgresql ubuntu free
Speaking of that, feel free to check various network bandwidth in Ubuntu. Sudo apt install postgresql postgresql-contribĮnter your password when asked and you should have it installed in a few seconds/minutes depending on your internet speed. In the terminal, use the following command to install PostgreSQL sudo apt update Method 1: Install PostgreSQL from Ubuntu repositories

Package: postgresqlīased on this information, you can make your mind whether you want to install the version available from Ubuntu or you want to get the latest released version of PostgreSQL. In my Ubuntu 18.04, it showed that the available version of PostgreSQL is version 10 (10+190 means version 10) whereas PostgreSQL version 11 is already released. However, like many other development tools, it may not be the latest version.įirst check the PostgreSQL version available in Ubuntu repositories using this apt command in the terminal: apt show postgresql When writing apps that utilize PostgreSQL, you should create a different user account with fewer privileges so that the app (and anyone that may hack it) doesn’t obtain access to all your other databases and user accounts.PostgreSQL is available in Ubuntu main repository. This means you’d use your admin account to type the following command (you don’t have to be logged in as root, just use an account that has ‘sudo’ privileges): sudo -i -u postgresĪfterwards, you should get a prompt that looks something like this, then you’d type ‘psql’ and you’ll now have access to your PostgreSQL instance: psql ‘postgres’ is the default PostgreSQL username on Ubuntu and that is the user you’ll have to use to log into a new PostgreSQL installation for the first time. To log into PostgreSQL via the command line on Ubuntu, you have to switch to the user ‘postgres’ using a privileged user’s account. If you’re looking for the default password for PostgreSQL on Ubuntu, there is none.
