Tuesday, July 21, 2015

MySQL Quick Start Guide

sudo yum install php
     if it isn't installed already (check using 'which php')
sudo yum install mysql-server 
     installing the mysql server 
sudo yum install mysql 
     installing mysql 
sudo /sbin/service mysqld start 
      starts mysql
sudo /usr/bin/mysql_secure_installation 
      Starts the settings
sudo /sbin/service mysqld start 

      starts mysql   
sudo chkconfig mysqld on 
      sets mysql to start at boot




                                        MySQL QUICK REFERENCE
Access to mysql shell:
 
     /usr/bin/mysql -u root -p 
       -or-
              mysql -u <username(could be root)> -p

Creates user
      CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';

Grants all permissions to the user:   
   
      GRANT ALL ON <database name>.* TO '<username>'@'localhost';    
       
To create a database:


    CREATE DATABASE <database name>;

To show databases:
    SHOW databases;

To select the database(not done automatically):

    USE <database name>;

To create the format of the data base:
   
    CREATE TABLE <name of table>
    EX: CREATE TABLE pet (name VARCHAR(20), species VARCHAR(20),owner              ->VARCHAR(20), birth DATE);

Appending files to the data base (MUST FOLLOW FORMAT OF TABLE):
       
   LOAD DATA LOCAL INFILE '<path to file>' INTO TABLE <table name>;

Adding one set of values to the table:

   INSERT INTO <table name> VALUES(<values following table format>);

   Ex: INSERT INTO pet VALUES ('Matt Kearney','sloth','Akhil Jacob','1999-03-30');


View the Table:
   SELECT * FROM <database name>


1 comment: