--A style in which you can hit commands and proceed to the process immediately before development, and adjust detailed settings by looking at the reference site ――It feels like you're pushing forward with the aim of creating an environment where you can move. --Since we are doing it as part of building the environment to run django, there are some descriptions other than postgreSQL and the description for running postgreSQL without a password.
--Docker installation is complete ――I don't remember having a hard time, so I think I put it in quickly by looking at the official page or reference page. --For reference, it is a link to Official page --Running in mac environment (10.14.6)
nothing special.
docker-compose.yml
version: '3'
services:
db:
image: postgres
environment:
POSTGRES_HOST_AUTH_METHOD: 'trust'
volumes:
- ./database:/var/lib/postgresql/data
To check the operation on docker, start PostgreSQL on Docker and make bash running in advance. Execute the following command in the terminal.
#Start the container (""-Add "d" to run in the background)
docker-compose up -d
#Check the container name
docker ps
#Connect to container
docker exec -it {postgreSQL container name} bash
#Login to postgreSQL
psql -U postgres
--User created
--Create user
create role {role name} with login password '{password}';
--Confirmation of creation result
\du
It is assumed that roles will be assigned separately, but this article will not cover them. Please refer to this page and create it if necessary. https://www.dbonline.jp/postgresql/role/index2.html#section1 https://www.dbonline.jp/postgresql/role/index3.html
--Create database
--Creating a database
create database {database name};
--View database list
\l
--Schema creation
--Creating a schema
CREATE SCHEMA {schema name};
create schema anpi;
--Schema list
\dn
--Create table
--Creating a table
create table {schema name}.{table name};
--Table list
\dt {schema name}.*;
Recommended Posts