Skip to content

Instantly share code, notes, and snippets.

@RobertoMachorro
Last active September 7, 2022 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertoMachorro/7d2ac7fa882aabd84fd6517e7242b208 to your computer and use it in GitHub Desktop.
Save RobertoMachorro/7d2ac7fa882aabd84fd6517e7242b208 to your computer and use it in GitHub Desktop.
Setup New Database with User

Setup New Database with User

MySQL

SHOW DATABASES;

CREATE DATABASE IF NOT EXISTS vapor_database
CHARACTER SET utf8
COLLATE utf8_unicode_ci;

CREATE USER 'vapor_username'@'localhost' IDENTIFIED BY 'vapor_password';
GRANT ALL PRIVILEGES ON vapor_database.* TO 'vapor_username'@'localhost';
FLUSH PRIVILEGES;

PostgreSQL

CREATE USER vapor_username;
CREATE DATABASE vapor_database;
GRANT ALL PRIVILEGES ON DATABASE vapor_database TO vapor_username;
ALTER USER vapor_username WITH PASSWORD 'vapor_password';

MongoDB

use vapor_database
db.createUser({
	user: "vapor_username",
	pwd:  passwordPrompt(), // or cleartext password
	roles: [ { role: "readWrite", db: "vapor_database" } ]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment