Zoyinc
  • Home
  • Contact
  • Categories
    • CD Archiving
    • GIMP
    • Linux
    • MythTV
    • Open Media Vault
    • Technology
    • VMware
    • WordPress
    • YouTube
  • About


Resetting a PostgreSQL root password

By

Tony

,

August 20, 2013

Recently I upgraded to the latest Postgres version. I had a number of pain points doing this including not being able to start the DBs because the version upgrade was too big – had to export from old version and import to new. But one of the problems was that for some reason my password didn’t work.

One of the more important config files in Postgres is pg_hba.conf. It is the one that controls access. In my case the uncommented bit looks like:

   # TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

   # "local" is for Unix domain socket connections only
   local   all         all                               password
   # IPv4 local connections:
   host    all         all         192.168.0.0/16          md5
   host    all         all         127.0.0.1/32            md5

Running on Fedora 18 this is located in:

/var/lib/pgsql/data/pg_hba.conf

To reset the password you need to change the first line from “password” to “trust” this means that it will log you in with the Unix account “postgres” rather than the Postgres account “root”. So change the file as below:

#local   all         all                               password
local   all         all                               trust

You will need to restart Postgres for it to be effective !

The following commands should reset the password:

su – postgres
psql -U postgres
ALTER USER postgres WITH PASSWORD 'mySuperSecretpassword';
\q

Obviously the above assumes you are running Postgres under the account “postgres”. Note that “/q” is the command to exit psql.

Obviously afterwards you need to undo the change to “pg_hba.conf” and restart PosgreSQL

Related

CentOS 7 VM for WordPress and MythTV – Post install setup
Problems with single quotes, JSP and PostgreSQL
Enabling SSH access to Debian live USB
Backup and restore WordPress
Recent

  • AlmaLinux GUI – no taskbar or application shortcuts

    AlmaLinux GUI – no taskbar or application shortcuts

  • AlmaLinux 9.5 base VM

    AlmaLinux 9.5 base VM

  • Reset Kodi thumbnails

    Reset Kodi thumbnails

  • Set default settings values in Kodi skins

    Set default settings values in Kodi skins

  • Add/Remove/Reset music/video libraries in Kodi

    Add/Remove/Reset music/video libraries in Kodi

  • Zoyinc Kodi skin on Sony TV

    Zoyinc Kodi skin on Sony TV

  • [L] – WordPress UAM Locked Post

    [L] – WordPress UAM Locked Post

  • Import Pictures and Videos – images not previewed

    Import Pictures and Videos – images not previewed

  • Find My Train

    Find My Train

  • WordPress style name not visible

    WordPress style name not visible

About Zoyinc

  • Contact Us
  • Zoyinc Disclaimer
  • Google Search Console
  • Privacy Policy
  • Site Statistics
  • Login

Apache Auckland Backup CD CentOS Centos7 Children Configuration Debian Error ESX ESXi Fedora Firewall Install Josh Kids Kodi Linux MariaDB MySQL MythTV New Zealand OKD OMV Open Media Vault OpenShift PHP Player Python RAID RedHat Red Hat Rip School Setup SMB SonicWALL Spark tags Train Trains VLAN VM VMware Weaver Windows WordPress YouTube

Powered by

This site is licensed under a Creative Commons Attribution 4.0 International License.