Last active
April 3, 2020 10:35
-
-
Save princefishthrower/d0951faed76c669605359f0186cf4f98 to your computer and use it in GitHub Desktop.
Create role, create database, grant privledges on database, connect to database, create table, grant privledges to that table command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
***Issue the following commands in the terminal after logging in with 'psql' | |
***If you copy paste, note that the new user will be 'new_user' with password 'mysupercoolpassword' | |
***with database 'new_database' and table 'new_table': | |
CREATE ROLE new_user WITH LOGIN PASSWORD 'mysupercoolpassword'; | |
CREATE DATABASE new_database; | |
GRANT ALL PRIVILEGES ON DATABASE new_database TO new_user; | |
\connect new_database; | |
CREATE TABLE new_table(id int, some_string varchar, cool_big_int bigint, PRIMARY KEY (id)); | |
GRANT ALL PRIVILEGES ON TABLE new_table TO new_user; | |
***Then the following may be useful in your .bash_profile, .profile, or similiar: | |
export project_name_DB=new_database | |
export project_name_DB_USER=new_user | |
export project_name_DB_PASSWORD=mysupercoolpassword | |
export project_name_DB_HOST=127.0.0.1 | |
export project_name_DB_PORT=5432 | |
Copy and paste this gist into any favorite text editor and modify it to your needs! (Hint: it's designed to use Cmd+D in Atom or Sublime text so all the variables correspond with eachother! Happy hacking! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment