Skip to content

Instantly share code, notes, and snippets.

View AtulKsol's full-sized avatar

Atul Khanduri AtulKsol

View GitHub Profile
@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
View brew_elasticsearch.sh
brew tap homebrew/versions
brew cask install java
brew search elasticsearch
brew install elasticsearch@2.3
brew services start elasticsearch@2.3
@AtulKsol
AtulKsol / elasticsearch_commands.md
Created October 17, 2019 07:56
ElasticSearch Commands for Mac
View elasticsearch_commands.md
@AtulKsol
AtulKsol / postgres-not-running-fix.md
Last active December 22, 2022 05:10
Postgres on OSX with homebrew not running
View postgres-not-running-fix.md
@AtulKsol
AtulKsol / db_backup_commands.md
Last active September 15, 2023 16:52
Commands to backup & restore database
View db_backup_commands.md
  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 / multiple_ssh_setting.md
Created June 5, 2017 06:31 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md
@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.
View rails_load_path_tips.md
@AtulKsol
AtulKsol / docker-commands.md
Last active June 3, 2019 07:41
Docker commands
View docker-commands.md

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 / psql-error-fix.md
Last active September 2, 2023 03:27
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)
View psql-error-fix.md

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