Skip to content

Instantly share code, notes, and snippets.

@rdlmda
Last active August 23, 2016 19:07
Show Gist options
  • Save rdlmda/9040614 to your computer and use it in GitHub Desktop.
Save rdlmda/9040614 to your computer and use it in GitHub Desktop.
Some very basic MySQL operations
Some very basic MySQL operations
# This comment continues to the end of line
-- This comment continues to the end of line
/* this is an in-line comment */
/*
this is a
multiple-line comment
*/
# Create a new user, a new DB and grant privileges on this DB
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT USAGE ON `database`. * TO 'username'@'localhost' IDENTIFIED BY 'password' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
CREATE DATABASE IF NOT EXISTS `database` ;
GRANT ALL PRIVILEGES ON `database` . * TO 'username'@'localhost';
mysqldump --databases -u [user] -p [database] | gzip > [filename.sql.gz]
gunzip < [compressed_filename.sql.gz] | mysql -u [user] -p[password] [databasename]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment