Skip to content

Instantly share code, notes, and snippets.

@numoonchld
Last active August 2, 2018 17:51
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 numoonchld/6c0dbcddc1c7111f1113b70bdeb73136 to your computer and use it in GitHub Desktop.
Save numoonchld/6c0dbcddc1c7111f1113b70bdeb73136 to your computer and use it in GitHub Desktop.
LAMP Setup - mySQL CheatSheet
## Install mySQL -------------------------------
sudo mysql_secure_installation
# Login to mySQL
sudo mysql –u root –p
## Setup mySQL databases: -------------------------------
# Create Database for wordpress
CREATE DATABASE databaseName;
# View list of databases
show databases;
# Set active database/ Switch database
USE databaseName;
# Delete a database
DROP DATABASE databaseName;
## Setup mySQL user: -------------------------------
# See all users
select host, user from mysql.user;
# Create a user
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'set_password';
## Grant user privileges: -------------------------------
# grant new user all privileges
GRANT ALL PRIVILEGES ON databaseName.tableName TO 'newuser'@localhost IDENTIFIED BY 'set_password';
# refresh the database
FLUSH PRIVILEGES;
# exit mySQL
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment