SlideShare a Scribd company logo
Page 1
MY SQL INSTALLATION AND
CONFIGERATION WITH QUERY
BY ,
A.ANANDHA GANESH
(SMK FOMRA INSTITUTE OF TECHNOLOGY)
Page 2
INTRODUCTION:
MySQL, the most popular Open Source SQL database management system, 
is developed, distributed, and supported by MySQL AB. 
MySQL AB is a commercial company, founded by the MySQL developers. 
It is a second generation Open Source company that unites 
Open Source values and methodology with a successful business model. 
Page 3
MySQL is a fast, stable and true multi­user, 
multi­threaded SQL database server. 
SQL (Structured Query Language) is the most popular 
database query language in the world. 
The main goals of MySQL are speed, robustness and ease of use.
Page 4
Installing MySQL on Linux
It's simple to install MySQL on Linux using the RPM file.
   1. Become the superuser if you are working in your account. 
(Type "su" and the prompt and give the root password).
   2. Change to the directory that has the RPM download.
   3. Type the following command at the prompt:
      rpm ­ivh "mysql_file_name.rpm"
      Similarly you can also install the MySQL client and MySQL development RPMs 
if you've downloaded them.
      Alternatively, you can install the RPMs through GnoRPM (found under System).
   
Page 5
You can check your configuration using the following command
#netstat ­tap
Output Looks like below
tcp 0 0 *:mysql *:* LISTEN 4997/mysqld
MySQL comes with no root password as default. 
This is a huge security risk. You’ll need to set one.
 So that the local computer gets root access as well, you’ll need to
 set a password for that too. 
The local­machine­name is the name of the KonaLink1KonaLink1computer you’re working on. 
For more information see here
#mysqladmin ­u root password your­new­password
#mysqladmin ­h root@local­machine­name ­u root ­p password your­new­password
#/etc/init.d/mysql restart
Page 6
4. Now we'll set a password for the root user. Issue the following at the prompt.
      mysqladmin ­u root password mysqldata
      where mysqldata is the password for the root. (Change this to anything you like).
5. It is now time to test the programs. Typing the following at the prompt starts
 the mysql client program.
mysql ­u root ­p
The system
asks for the the password. Type the root password (mysqldata).
If you don't get the prompt for password, it might be because MySQL Server is not running
To start the server, change to
 /etc/rc.d/init.d/ directory and issue the command ./mysql start 
(or mysql start depending on the value of the PATH variable on your system). 
Now invoke mysql client program.
 
Page 7
6. Once MySQL client is running, you should get the mysql> prompt.
 Type the following at this prompt:
show databases;
7. You should now get a display similar to:
+­­­­­­­­­­­­­­­­+
| Database       |
+­­­­­­­­­­­­­­­­+
| mysql          |
| test           |
+­­­­­­­­­­­­­­­­+
2 rows in set (0.00 sec)
Page 8
•Configuring Your Application
After creating and testing the database,
 you need to inform your application
 of the database name, 
the IP address of the database client server, 
and the username and password of 
the application's special MySQL user that will be accessing the data. 
Page 9
Frequently this registration process is done by the editing 
of a special application­specific configuration file either 
via a Web GUI or from the command line.
 Read your application's installation guide for details. 
You should always remember that MySQL is just a database that your application 
will use to store information. 
The application may be written in a variety of languages with Perl and PHP being the
most popular. The base PHP and Perl RPMs are installed with Fedora Linux by default,
 but the packages used by these languages to talk to MySQL are not. 
You should also ensure that you install the RPMs
 listed in Table 34.1 on your MySQL clients to ensure compatibility.
 Use the yum utility discussed in Chapter 6, "Installing Linux Software", 
if you are uncertain of the prerequisite RPMs needed. 
Page 10
– Table 34.1 Required PHP and Perl RPMs for MySQL Support
RPM RPM
php-mysql MySQL database specific support for PHP
perl-DBI Provides a generic Perl interface for interacting with
relational databases
perl-DBD-MySQL MySQL database specific support for Perl
Page 11
BASIC MySQL COMMANDBASIC MySQL COMMAND
* CREATE TABLE syntax
* DROP TABLE syntax
* DELETE syntax         
* SELECT syntax            
* JOIN syntax                 
* INSERT syntax          
* REPLACE syntax      
* UPDATE syntax    
Page 12
BASIC QURIESBASIC QURIES
CREATE TABLECREATE TABLE
         This command is used to create structure of the table.
        SyntaxSyntax:
         Create table <tablename>(list of col                            
Definition1,....);
     Example:Example:
          Create table emp1 (Emp ID (number(3)                    
primary key, Name(varchar(20), Age(number(),           
DOB(date));
Page 13
DROP TABLEDROP TABLE
Syntax:Syntax:
    Drop table [if exists]  tbl_name
                         
Explanation:Explanation:                                                          
     DROP TABLE removes one or more tables. All table data and 
the table definition are removed.You can use the keywords IF 
EXISTS to prevent an error from      occurring for tables that 
don't exist.                           
Page 14
DELETEDELETE
Syntax:
        Delete from <tablename>;
 Example:
        Delete from emp1;
Explanation:
      This command is used to delete the rows and column.
Page 15
 SELECT
Syntax:Syntax:
      Select * from <tablename>;
Example:Example:
      Select * from emp1;
Explanation:
      This command is used to describe the structure of the table.
Page 16
INSERT VALUEINSERT VALUE
  Syntax:
     Insert into <tablename> values (list of values);
  Example:
    Insert into emp1 values (11, Anu, 20,30­aug­1989);
 Explanation:
     This command is used to insert values into the structure of the 
table.
Page 17
REPLACEREPLACE 
Syntax:Syntax:
          REPLACE  [INTO] tbl_name [(col_name,...)] VALUES 
(expression,...)
Explanation:Explanation:                                                         
            REPLACE works exactly like INSERT, except that if an old 
record in the table has the same value as a new record on a unique 
index, the old record is  deleted before the new record is inserted.    
                                                  
Page 18
UPDATEUPDATESyntax:Syntax:
UPDATE [table] SET [column]=[value] WHERE [criteria]
UPDATE Used_Vehicles SET mileage=66000 WHERE vehicle_id=1;
UPDATE [table] SET [column]=[value] WHERE [criteria]
Example:
UPDATE Used_Vehicles SET mileage=66000 WHERE
vehicle_id=1;
Explanation:
UPDATE updates columns in existing table rows with new
values. The SET clause indicates which columns to modify and the
values they should be given. The WHERE clause, if given,
specifies which rows should be updated. Otherwise all rows are
updated.
Page 19
ADVANCED COMMANDSADVANCED COMMANDS

AS                                 

ALTER and ADD         

UNION JOIN               

TEMPORARY Table   

TRUNCATE Table      
Page 20
ASAS
Syntax:
   SELECT <columns>FROM <existing_table_name>AS 
<new_table_name>
Example:                                                                                
SELECT t1.name ­> FROM artists ­> AS t1;                               
                  
Explanation:                                                                             It is 
used to create a shorthand reference to elements with long 
names to make the SQL statements shorter and reduce the 
chance of typos in the longer names. 
Page 21
ALTERING THE DATABASE ALTERING THE DATABASE 
STRUCTURE AND  ADDING DATASTRUCTURE AND  ADDING DATA
Syntax:
ALATER TABLE tablename
ADD clm_name type
Example:Example:                                               
ALTER TABLE cds 
    ­>  ADD producerID INT(3); 
Page 22
UNION JOINSUNION JOINS
Syntax: 
Select <fields>from <table> where <condition> union
SELECT <fields>  FROM <table>WHERE <condition>
Example:                                   
 SELECT artist FROM artists WHERE (artists.name LIKE 'P%')  
UNION
    SELECT artists.name FROM artists WHERE (artists.name LIKE 'G
%');
Explanation:                                                                   
         Union Joins allow the results of two queries to be combined 
into one outputted result set. This is done by having the 2 (or 
more) queries glued together by the UNION operator.
Page 23
CREATING THE TEMPORARY TABLECREATING THE TEMPORARY TABLE
Definition:                                                                                 
          The syntax for creating temporary tables is almost identical 
that used for creating a normal table. Except that there is an extra 
TEMPORARY clause. 
Syntax:                                                                                               
        CREATE TEMPORARY TABLE <table> (field definition)             
            CREATE TEMPORARY TABLE <newtable>SELECT * 
FROM <oldtable>          
     
Page 24
TRUNCATE TABLETRUNCATE TABLE
Syntax:                                                                                  
TRUNCATE TABLE <table_name>
Example:                                                                             
TRUNCATE TABLE emp1;
Page 25
TRUNCATE( )TRUNCATE( )
Syntax:                                                                    
TRUNCATE(X,D)
Use:                                                                          
This function is used to return the value of X truncated to D number 
of decimal places. 
Page 26
INSERT( )INSERT( )
Syntax:                                                                    
INSERT(str,pos,len,newstr)
Use:                                                                         
Returns the string str, with the substring beginning at position pos 
and len characters long replaced by the string newstr. 
Page 27
SQL Constraints:
Constraints are used to limit the type of data that can go into a table.
Constraints can be specified when a table is created (with the CREATE TABLE
statement) or after the table is created (with the ALTER TABLE statement).
We will focus on the following constraints:
NOT NULL
UNIQUE
PRIMARY KEY
FOREIGN KEY
CHECK
DEFAULT
Page 28
The TOP Clause
The TOP clause is used to specify the number of records to return.
The TOP clause can be very useful on large tables with thousands of records. Returning a large number of records
can impact on performance.
Note: Not all database systems support the TOP clause.
SQL Server Syntax
SELECT TOP number|percent column_name(s)
FROM table_name
examble:
SELECT TOP 2 * FROM Persons
P_Id LastName FirstName Address City
1 HansenOla Timoteivn 10 Sandnes
2 Svendson ToveBorgvn 23 Sandnes
Page 29
The LIKE Operator
The LIKE operator is used to search for a specified pattern in a column.
SQL LIKE Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
EXAMPLE:
SELECT * FROM Persons
WHERE City LIKE 's%'
P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10
Page 30
To export a database, use the mysqldump utility normally located 
in  your  mysql/bin  directory  .  For  example,  to  export  all  the 
tables and data for a database named guestdb.
Syntax:Syntax:
mysqldump guestdb > guestdb.txt
Exporting a DatabaseExporting a Database
Page 31
This will create a text file containing all the commands necessary to 
recreate all the tables and data found in guestdb. However, what if I 
want to export only one table? To do this the command is modified as 
follows assuming guestTbl is the table to be exported.
Syntax:
mysqldump guestdb guestTbl > guestdb.txt
Page 32
With  the  data  in  a  text  file,  its  time  to  import  the  data  back  into 
MySQL. This can be done by passing the commands contained in 
the text file into the MySQL client. 
For example:
mysql ­p ­­user=username < guestdb.txt
This passes all the commands in the file into the mysql client just like 
you were typing them in.
Importing the DatabaseImporting the Database

More Related Content

What's hot (18)

PPTX
Why you should(n't) run your databases in the cloud
Microsoft TechNet - Belgium and Luxembourg
 
PDF
Sql2008 (1)
YanivGupta
 
PPTX
Databases overview &amp; concepts
Parag Patil
 
PDF
Using MS-SQL Server with Visual DataFlex
webhostingguy
 
PDF
Sql server difference faqs- 5
Umar Ali
 
PDF
Cloudera ref arch_azure
raivikash
 
PPT
Mysqlppt3510
Khan Rahimeen
 
PDF
Execution plan basics
Kaing Menglieng
 
PDF
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Keith Hollman
 
PDF
MySQL InnoDB Cluster HA Overview & Demo
Keith Hollman
 
PPT
Ebook10
kaashiv1
 
PPTX
DEE 431 Introduction to Mysql Slide 3
YOGESH SINGH
 
PPTX
Diving into sql server 2016
Mohamed Zaatar - MSc
 
PPTX
http://www.hfadeel.com/Blog/?p=151
xlight
 
PPTX
SQL Server 2016: Just a Few of Our DBA's Favorite Things
Hostway|HOSTING
 
PPTX
SQL Server 2016 New Features and Enhancements
John Martin
 
DOCX
Create column store index on all supported tables in sql server 2014 copy
Mustafa EL-Masry
 
PDF
Introducing Microsoft SQL Server 2012
Intergen
 
Why you should(n't) run your databases in the cloud
Microsoft TechNet - Belgium and Luxembourg
 
Sql2008 (1)
YanivGupta
 
Databases overview &amp; concepts
Parag Patil
 
Using MS-SQL Server with Visual DataFlex
webhostingguy
 
Sql server difference faqs- 5
Umar Ali
 
Cloudera ref arch_azure
raivikash
 
Mysqlppt3510
Khan Rahimeen
 
Execution plan basics
Kaing Menglieng
 
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Keith Hollman
 
MySQL InnoDB Cluster HA Overview & Demo
Keith Hollman
 
Ebook10
kaashiv1
 
DEE 431 Introduction to Mysql Slide 3
YOGESH SINGH
 
Diving into sql server 2016
Mohamed Zaatar - MSc
 
http://www.hfadeel.com/Blog/?p=151
xlight
 
SQL Server 2016: Just a Few of Our DBA's Favorite Things
Hostway|HOSTING
 
SQL Server 2016 New Features and Enhancements
John Martin
 
Create column store index on all supported tables in sql server 2014 copy
Mustafa EL-Masry
 
Introducing Microsoft SQL Server 2012
Intergen
 

Viewers also liked (12)

PDF
MySQL creative programming
Giuseppe Maxia
 
PDF
A MySQL Odyssey - A Blackhole Crossover
Keith Hollman
 
ODP
Mysql1
rajikaa
 
PPTX
MySql Triggers Tutorial - The Webs Academy
thewebsacademy
 
PPTX
Terminal Commands (Linux - ubuntu) (part-1)
raj upadhyay
 
PPT
Linux Commands
Ramasubbu .P
 
PPTX
Basic commands of linux
shravan saini
 
PPT
MYSQL.ppt
webhostingguy
 
PPT
MySql slides (ppt)
webhostingguy
 
PPT
MySQL Atchitecture and Concepts
Tuyen Vuong
 
MySQL creative programming
Giuseppe Maxia
 
A MySQL Odyssey - A Blackhole Crossover
Keith Hollman
 
Mysql1
rajikaa
 
MySql Triggers Tutorial - The Webs Academy
thewebsacademy
 
Terminal Commands (Linux - ubuntu) (part-1)
raj upadhyay
 
Linux Commands
Ramasubbu .P
 
Basic commands of linux
shravan saini
 
MYSQL.ppt
webhostingguy
 
MySql slides (ppt)
webhostingguy
 
MySQL Atchitecture and Concepts
Tuyen Vuong
 
Ad

Similar to My sql (20)

ODP
Sql installation
Balakumaran Arunachalam
 
PDF
Instalar MySQL CentOS
Moisés Elías Araya
 
PPT
Mysql
Mindtree
 
PPT
Mysql ppt
Sanmuga Nathan
 
PDF
BITS: Introduction to MySQL - Introduction and Installation
BITS
 
PPS
Linux17 MySQL_installation
Jainul Musani
 
PDF
Getting started with my sql
Web Sky
 
PDF
Mysql tutorial
Pankaj Sipl
 
PDF
How to Install MySQL on Debian 12 In Just 8 Steps.pdf
Green Webpage
 
PDF
SULTHAN's PHP, MySQL & wordpress
SULTHAN BASHA
 
PPTX
My sql administration
Mohd yasin Karim
 
PPTX
My sql on linux
kjwunderle
 
PPTX
Build MySQL virtual enviroment
Taras Vasylyuk
 
PPTX
MySQL DBA OCP 1Z0-883
Kwaye Kant
 
PDF
My SQL 101
Dave Stokes
 
PDF
Mysql administration
beben benzy
 
PDF
Percona Live '18 Tutorial: The Accidental DBA
Jenni Snyder
 
PDF
Curso de MySQL 5.7
Eduardo Legatti
 
PDF
Welcome to MySQL
Grigale LTD
 
PPT
My sql with querys
NIRMAL FELIX
 
Sql installation
Balakumaran Arunachalam
 
Instalar MySQL CentOS
Moisés Elías Araya
 
Mysql
Mindtree
 
Mysql ppt
Sanmuga Nathan
 
BITS: Introduction to MySQL - Introduction and Installation
BITS
 
Linux17 MySQL_installation
Jainul Musani
 
Getting started with my sql
Web Sky
 
Mysql tutorial
Pankaj Sipl
 
How to Install MySQL on Debian 12 In Just 8 Steps.pdf
Green Webpage
 
SULTHAN's PHP, MySQL & wordpress
SULTHAN BASHA
 
My sql administration
Mohd yasin Karim
 
My sql on linux
kjwunderle
 
Build MySQL virtual enviroment
Taras Vasylyuk
 
MySQL DBA OCP 1Z0-883
Kwaye Kant
 
My SQL 101
Dave Stokes
 
Mysql administration
beben benzy
 
Percona Live '18 Tutorial: The Accidental DBA
Jenni Snyder
 
Curso de MySQL 5.7
Eduardo Legatti
 
Welcome to MySQL
Grigale LTD
 
My sql with querys
NIRMAL FELIX
 
Ad

More from anandha ganesh (6)

ODP
Htmltag.ppt
anandha ganesh
 
ODP
Appache.ppt
anandha ganesh
 
PPT
Anandha ganesh linux1.ppt
anandha ganesh
 
Htmltag.ppt
anandha ganesh
 
Appache.ppt
anandha ganesh
 
Anandha ganesh linux1.ppt
anandha ganesh
 

Recently uploaded (20)

PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
July Patch Tuesday
Ivanti
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Python basic programing language for automation
DanialHabibi2
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 

My sql