Skip to content

Installation and Usage Guide for MySQL

September 18, 2012

In Progress….

 

Install

Windows

Coming Soon

Linux

$ sudo yum install mysql-server mysql
$ sudo yum upgrade mysql-server mysql
$ sudo chkconfig mysqld on

Mac

Note you will need HomeBrew. Here’s a link to install it if you need to.


$ brew install mysql

 

Using MySQL from the Command Line

Start Mysql

Normal Start

$ mysqld

Start on Linux

$ sudo service mysqld start

Connect Via Commandline

Connect to MySQL as current user

$ mysql

Connect to MySQL as root

$ sudo mysql

Connect to MySQL with credentials

$ mysql --user={user_name} --password={user_password}

User Commands

List Users

mysql> SELECT User FROM mysql.user;

Create User

mysql> CREATE USER '{user_name}' IDENTIFIED BY '{user_password}';

Grant User All Privileges

mysql> GRANT ALL PRIVILEGES ON *.* TO '{user_name}' WITH GRANT OPTION;

Useful Commands

Show All Databases


mysql> SHOW DATABASES;

Create a new DB


mysql> CREATE DATABASE {database_name};

Select a Database

mysql> USE {database_name};

List all tables in current Database


mysql> SHOW TABLES;

Import and Export Data

Export DB to file


$ mysqldump -h hostname -u user --password=password databasename > filename

Import data from file into DB


$ mysql -h hostname -u user --password=password databasename < filename

Advertisements

From → Guide, Installation

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: