I'm setting up a Rails app on a fresh Ubuntu installation and created the Postgres databases using rake db:create:all. In databases.yml, the password field for all databases is left blank. I'm trying to do a pg_restore of a dump I captured from the app's production deployment, but I keep being prompted for a password. I have a feeling this is something to do with the settings in the pg_hba.conf file, but I can't remember how I had them set in my previous Ubuntu installation. How do I get Postgres to trust pg_restore for local connections? Or is there something different causing this issue?
When restoring a PostgreSQL dump using pg_restore , you usually add the --clean flag to remove any existing data from tables. Note that this only removes data from tables that are part of the dump and will not remove any extra tables. You need to do that yourself.
Type the current password for the specified user type in the Current password field. If you upgraded from version 5.2. 1, the default Postgres database password is postgres .
Edit the pg_dba. conf file and change all local connections from md5 to trust. By doing this, you can log in to the PostgreSQL database server without using a password.
PostgreSQL database passwords are separate from operating system user passwords. The password for each database user is stored in the pg_authid system catalog. Passwords can be managed with the SQL commands CREATE ROLE and ALTER ROLE, e.g., CREATE ROLE foo WITH LOGIN PASSWORD 'secret' , or the psql command \password .
Set trust
(or peer
if you want to match postgresql user names to unix user names) for local
connections in pg_hba.conf
. You pretty much answered it in your question.
If you're specifying -h localhost
explicitly then you're using TCP/IP, so you'll need to either omit -h localhost
, use -h /tmp
or wherever your unix_socket_directory
is configured to live, or set trust
for host
connections from 127.0.0.1/32
in pg_hba.conf
as well.
See pg_hba.conf
and client authentication.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With