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.
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
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
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.
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).
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