Skip to content

Instantly share code, notes, and snippets.

@adini121
Last active February 3, 2016 07:01
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 adini121/d5adaf7edf73c83518e3 to your computer and use it in GitHub Desktop.
Save adini121/d5adaf7edf73c83518e3 to your computer and use it in GitHub Desktop.
Useful mysql commands

##(My)sql commands I encountered throughout my sql-experience

####Basics #####Create database and tables

DROP DATABASE IF EXISTS database_name;

CREATE DATABASE database_name DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Grant permissions
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON database_name.* TO 'user'@'localhost' IDENTIFIED BY 'password';

All about tables

Describe all details about table

DESCRIBE name_of_table;

Dump mysql single table

To export

mysqldump -u -p database_name table_name > /path/to/file/table_name.sql

To import

mysql -u -p database < /path/to/file/table_name.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment