Tuesday 13 December 2011

### MySQL ###



  1. DBMS Engine
  2. Compabtible with various front-ends:
   a. Perl
   b. PHP
   c. ODBC
   d. GUI Management

Tasks:
  1. Install MySQL Client & Server
   a. yum -y install mysql

/etc/my.cnf - primary config file
/usr/bin/mysql - primary client used to interact with the server
/usr/bin/mysqladmin - primary admin utility to return useful info, and perform admin tasks from the shell

   b. yum -y install mysql-server

/usr/libexec/mysqld - DBMS engine

  2. Start MySQL server and modify perms for 'root'
   a. service mysqld start
   b. chkconfig --level 35 mysqld on
   c. mysqladmin -u root password abc123


  3. Install 'mysql' client on a remote system and test connectivity
   a. yum -y install mysql
   b. mysql -u root -p

Note: mysql command-line options ALWAYS override global (/etc/my.cnf), and/or local (~/.my.cnf) configuration directives


Note: MySQL Users consist of the following:
   a. username i.e. 'root'
   b. host i.e. 'localhost'
A sample username is: 'root@localhost'

  4. Secure 'anonymous' account
   a. DELETE FROM mysql.user WHERE user = '';
   b. flush privileges;

  5. Create Database 'addressbook'
  
create database AddressBook;
use AddressBook;
create table contacts (`first_name` char(20), `last_name` char(20),
`bus_phone1` char(20), `email` char(30), PRIMARY KEY (`email`));


  6. Insert Data into 'contacts' table using INSERT

INSERT INTO contacts (first_name,last_name,bus_phone1,email) VALUES ('Kay','Mohammed','888.573.4943','kay@LinuxCBT.com');

  7. Delete record from 'contacts' table
DELETE FROM contacts WHERE email = 'kay1@LinuxCBT.com';

  8. Update a record in the 'contacts' table
UPDATE contacts SET email='kay2@LinuxCBT.com' WHERE first_name='Kay';

No comments:

Post a Comment