Skip to content

Instantly share code, notes, and snippets.

View AtulKsol's full-sized avatar

Atul Khanduri AtulKsol

View GitHub Profile
@AtulKsol
AtulKsol / psql-error-fix.md
Last active November 13, 2024 12:43
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

@AtulKsol
AtulKsol / docker-commands.md
Last active June 3, 2019 07:41
Docker commands

Container's IP Address

  • docker inspect CONTAINER-ID | grep IPAddress

Container IP address using docker-compose

  • docker-compose ip

Stop and remove all container

  • docker stop $(docker ps -a -q)
  • docker rm $(docker ps -a -q)
@AtulKsol
AtulKsol / rails_load_path_tips.md
Created December 25, 2016 17:26 — forked from maxim/rails_load_path_tips.md
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@AtulKsol
AtulKsol / multiple_ssh_setting.md
Created June 5, 2017 06:31 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@AtulKsol
AtulKsol / db_backup_commands.md
Last active September 15, 2024 12:29
Commands to backup & restore database
  1. pg_dump is a nifty utility designed to output a series of SQL statements that describes the schema and data of your database. You can control what goes into your backup by using additional flags.
    Backup: pg_dump -h localhost -p 5432 -U postgres -d mydb > backup.sql

    Restore: psql -h localhost -p 5432 -U postgres -d mydb < backup.sql

    -h is for host.
    -p is for port.
    -U is for username.
    -d is for database.

@AtulKsol
AtulKsol / postgres-not-running-fix.md
Last active December 22, 2022 05:10
Postgres on OSX with homebrew not running

Postgres on OSX with homebrew not running [tested in mac]

Fix for following issue:

$ psql
psql: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
@AtulKsol
AtulKsol / elasticsearch_commands.md
Created October 17, 2019 07:56
ElasticSearch Commands for Mac

Install using Homebrew:

brew tap elastic/tap # Tap elastic 
brew search elasticsearch # Will show available versions
brew install [email protected] # install specific version

Start ElasticSearch Server

brew services start [email protected]

@AtulKsol
AtulKsol / brew_elasticsearch.sh
Created April 27, 2020 09:03 — forked from evgeniy-trebin/brew_elasticsearch.sh
How to install specific version of elasticsearch via brew
brew tap homebrew/versions
brew cask install java
brew search elasticsearch
brew install [email protected]
brew services start [email protected]