Skip to content

Instantly share code, notes, and snippets.

@mr-karan
Forked from hofmannsven/README.md
Last active August 29, 2015 14:15
Show Gist options
  • Save mr-karan/ddb85a3781b336003ec9 to your computer and use it in GitHub Desktop.
Save mr-karan/ddb85a3781b336003ec9 to your computer and use it in GitHub Desktop.

MySQL Command Line Interface

Related tutorial: http://cd64.de/mysql-cli

Commands

Access monitor: mysql -u [username] -p (will prompt for password)

Show all databases: show databases;

Access database: mysql -u [username] -p [name-of-database] (will prompt for password)

Create new database: create database [name-of-database];

Select database: use [name-of-database];

Show all tables: show tables;

Show table structure: describe [name-of-table];

Create tables and columns: CREATE TABLE [name-of-table] ([name-of-column] VARCHAR(120), [name-of-another-column] DATETIME);

Logout: exit

alias mysql=/Applications/MAMP/Library/bin/mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment