VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04

⇱ How To Install and Use PostgreSQL on Ubuntu 18.04 | DigitalOcean


How To Install and Use PostgreSQL on Ubuntu 18.04

Updated on February 18, 2026
Not using Ubuntu 18.04?
Choose a different version or distribution.
Ubuntu 18.04
👁 How To Install and Use PostgreSQL on Ubuntu 18.04

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Former Senior Technical Writer at DigitalOcean, specializing in DevOps topics across multiple Linux distributions, including Ubuntu 18.04, 20.04, 22.04, as well as Debian 10 and 11.

👁 Mark Drake
Mark Drake
Author
Manager, Developer Education
See author profile

Former Technical Writer at DigitalOcean. Focused on SysAdmin topics including Debian 11, Ubuntu 22.04, Ubuntu 20.04, Databases, SQL and PostgreSQL.

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Hello guys can you add how to set up the postgres to allow authorized user to connect from postgres clients such as pgadmin . inshort allow remote access. because once we have access then its easy to manage database . then you dont always need the sql cmds . also we can directly connect our apps

Thank you very much! The post was really helpful.

@mdrake Thanks for the detailed step by step guide, I hope it will help many and really appreciate that DigitalOcean takes serious efforts for requests. cheers.

After this line sudo adduser sammy it ask me for Postgres password. What password is expected? Anything I add at this line it says “Sorry try again” and after three attends it says sudo: 3 incorrect password attempts

I don’t know my postgresql password install i can not connection it

Hi, following this tutorial I created a video tutorial and posted it on YouTube. I entered the configuration part also for PostGIS. The video is in Italian, but the English subtitles work discreetly https://youtu.be/NvM09ken26o

Hello, I am trying to deploy my rails app on digital ocean. and am following this article https://gorails.com/deploy/ubuntu/18.04 but when i am trying to run this command sudo apt-get install postgresql postgresql-contrib libpq-dev it is showing the following errors.

Building dependency tree 
Reading state information... Done
libpq-dev is already the newest version (11.2-1.pgdg16.04+1).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 postgresql : Depends: postgresql-11 but it is not going to be installed
 postgresql-contrib : Depends: postgresql-contrib-11
E: Unable to correct problems, you have held broken packages.```

What is the problem an what should i do.

[I am workign with my new user, not in root user]

Thank you

Hi, I ran into a bundle install issue where I couldn’t install my PG gem.

I had to run “sudo apt-get install libpq-dev” to get the right packages. Hope this helps anyone that may be stuck on installing the pg gem.

Hey guys. This tutorial does not describe how to add postgres user to the sudoers file. It seems it should be added right before the ‘Accessing a Postgres Prompt Without Switching Accounts’ section as I was unable to do this step or beyond. Thanks!

👁 Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

© 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.