Skip to content

Instantly share code, notes, and snippets.

@gitllermopalafox
Forked from hofmannsven/README.md
Created June 19, 2014 04:01
Show Gist options
  • Save gitllermopalafox/f5439f05c6be1c7bb286 to your computer and use it in GitHub Desktop.
Save gitllermopalafox/f5439f05c6be1c7bb286 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