Beginners write! Until you install postgreSQL on macOS catalina and make it available in rails 6.0.3.2

I'm new to programming and mac. Without knowing it, it took a lot of time to research various things. I decided to write it as my memorandum just in case, If there is any mistake, it would be really helpful if you could point it out to an expert m (-_-) m If you have any questions, such as those who are not experts, we will do our best to accommodate you. * As much as possible ^^; Thanking you in advance.


First, install postgresql with homebrew and make initial settings

Do the following in the terminal: It seems that the place can be anywhere. I ran it in the projects folder I created earlier. All subsequent work is done at the terminal unless otherwise stated.

brew install postgresql

And the following seems to be the initial setting.

initdb /usr/local/var/postgres -E utf8

Start and check the settings

First start.

brew services start postgresql

It seems that it is OK if Encoding is UTF8 below. Maybe you don't have to make the initial settings? ??

psql -l

And the end.

brew services stop postgresql

This is a setting that makes postgre easy to use (it seems)

I edited .zshrc directly under the home folder with vscode. Specifically, add the following.

export PATH="/usr/local/opt/postgres:$PATH"
export PGDATA="/usr/local/var/postgres"

Then execute the following from the terminal to start postgre.

source ~/.zshrc #Apply the changed settings.
postgres

LOG: 〜 LOG: 〜 LOG: 〜 It seems that it is OK if the screen looks like this. It stops at control + c.

From here, it is the setting of rails.

Create your favorite app with the rails 6.0.3.2 new command. But of course Don't forget -d postgresql ^^

How to set database.yml in config folder and create user with database creation authority

# database.in yml
default: &default
  adapter: postgresql
  encoding: utf8 #Change to utf8
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: <Any username> #add to
  password: #add to
  host: localhost #add to
#Terminal
brew services start postgresql #First start
createuser <Any username> -d
  #When you erase it, dropuser<Any username>

Once you've done that, you can do it with rails db: create (in any folder, of course).

Recommended GUI

The software called Postico was easy for me to use. I use it for free, but it's not so expensive You may buy it ^^ The completely free PSequel didn't work for me ^^;

Recommended Posts

Beginners write! Until you install postgreSQL on macOS catalina and make it available in rails 6.0.3.2
Install Rails on macOS Catalina
Ssh to Ubuntu on VirtualBox on your Mac and do it until you install Docker
Create Rails5 and postgresql environment with Docker and make pgadmin available
(Ruby on Rails6) Creating a database and displaying it in a view
Steps to install Maven on Mac and use it in Eclipse
Install and configure jenv on macOS
If you can't install java on Catalina
Install imagick on macOS Catalina + php 7.4 Note
Beginners create portfolio in Ruby on Rails
Rails new in Ruby on Rails ~ Memorandum until deployment 2
Until you install Gradle and output "Hello World"
Rails new in Ruby on Rails ~ Memorandum until deployment 1
[Ruby on Rails] How to install Bootstrap in Rails
Just put `clang 12.0.0` in macOS` Catalina` and put `ruby 3.0.0`
Until you create a Spring Boot project in Intellij and push it to Github