Skip to content

Instantly share code, notes, and snippets.

@boratanrikulu
Created August 31, 2019 18:04
Show Gist options
  • Save boratanrikulu/77ff7edd763fbb1d044355ebc9ead817 to your computer and use it in GitHub Desktop.
Save boratanrikulu/77ff7edd763fbb1d044355ebc9ead817 to your computer and use it in GitHub Desktop.
Postgresql Config - Roles

Kamp sırasında genel olarak herkes Postgresql ile sorun yaşamıştı. Bunun için geçici bir yöntem olarak database.yml'de kullanıcı adı olarak postgres vermenizi söylemiştik. Fakat bu geçici bir yoldu.

Bunun için doğru çözüm, postgres'te, sistemde kullandığınız kullanıcı adı ile aynı isimde bir rol oluşturmak. Aşağıdaki gibi oluşturabilirsiz.

Role'ler hakkında kaynak: https://www.postgresql.org/docs/current/sql-createrole.html

Postgres ayakta değil ise kaldırın.

systemctl start postgresql

Postgres kullancısına geçiş yapıp

sudo su - postgres

DB'e bağlanın

psql

Sistemde kullandığınız kullanıcı adı ile aynı isimde bir rol yaratın. Bu rolün CREATEDB ve LOGIN izinlerinin olması yeterli.

CREATE ROLE kullanici_adiniz CREATEDB LOGIN;

Herşey yolunda gittiyse kullanıcı adınız ile aynı bir rol oluşmuş olmalı. Database'de bunu görmek için aşağıdaki komutu kullanabilirsiz.

\du

DB'den çıkış yapın.

\q

Postgres kullanıcısından da çıkış yapın.

exit

Artık pg ile proje yarattığınızda sorun olmamalı.

cd ~/Desktop

rails new a_project_with_pg --database postgresl

cd a_project_with_pg && rails server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment