SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Introduction to MySQL

●   Introduction
●   Installation
●   SQL
●   Schema design
●   Perl



BITS/VIB Bioinformatics Training – Jun 24, 2011 – Luc Ducazu <luc@daphnia.com>
Introduction to MySQL

●   Introduction
●   Installation
●   SQL
●   Schema design
●   Perl




BITS/VIB Bioinformatics Training – Jun 24, 2011 – Luc Ducazu <luc@daphnia.com>
Databases
●   A database is a collection of data
    –   numbers
    –   dates
    –   text or labels
    –   …
●   A Database Management System
    –   Data storage
    –   Data retrieval
    –   Data manipulation
    –   Authentication & Authorization
Relational Databases
●   Rigid structure
●   2 dimensional tables: 
    –   columns (fields)
    –   rows (records)
Relational Databases
●   Model objects (entities) and their relationships
●   Eg a store sells products to customers
    –   Entities:
         ●   Customers
             Attributes: name, address, telephone number...
         ●   Products 
             Attributes: name, price...
    –   Relationships:
         ●   Sale
             Attributes: quantity, timestamp...
Relational Databases
●   MySQL Workbench:
    –   graphical representation of entities and relationships
    –   generates SQL statements to create database & tables
Relational Database Management 
           Systems (RDBMS)
●   Enforce data intergrity:
    Honors constraints on columns
●   Enforce referential integrity:
    Honors constraints on relations
●   See also: the 12 rules of Edgar Codd
    http://en.wikipedia.org/wiki/Codd%27s_12_rules
RDBMS
●   Commercial products:
    –   Oracle
    –   DB2 (IBM)
    –   MS SQL Server (Microsoft)
●   Open­source offerings:
    –   MySQL (Oracle)
        Forks:
         ●   MariaDB
         ●   Drizzle
    –   PostgreSQL
    –   SQLite
NoSQL
●   Key­value stores
    –   Berkeley DB
●   Document databases – unstructured data
    –   CouchDB
    –   MongoDB
    –   Cassandra (FaceBook)
●   See also: 
    http://en.wikipedia.org/wiki/Nosql
Introduction to MySQL

●   Introduction
●   Installation
●   SQL
●   Schema design
●   Perl




BITS/VIB Bioinformatics Training – Jun 24, 2011 – Luc Ducazu <luc@daphnia.com>
Installing MySQL on Linux
●   For DEB based Linux distributions
    (Debian, Ubuntu, …)
    # apt­get install mysql­server

●   For RPM based Linux distributions
    (RHEL, Fedora, CentOS, ...)
    # yum install mysql­server
Installing MySQL on Windows
●   An installable (MSI) package is available on the 
    MySQL site:
    http://www.mysql.com/
    –   Follow the 'Downloads (GA)' link
    –   Choose 'MySQL Community Server'
    –   Select 'Microsoft Windows' as platform
Running MySQL
●   To start / stop / restart the MySQL service:
    # service mysql start
    # service mysql stop
    # service mysql restart
●   When starting MySQL for the first time, the 
    system administrator is reminded that the MySQL 
    setup is not yet secured
Running MySQL
●   To check whether or not mysql is running 
    correctly:
    # service mysql status
    mysql start/running, process 3394

    # ps ­ef | grep mysql
    mysql  3394  1  0 12:09 ?  00:00:00  /usr/sbin/mysqld

    # netstat ­ltpn | grep mysql
    tcp 0 0  0.0.0.0:3306  0.0.0.0:*  LISTEN  3394/mysqld 
Exercises
●   Install MySQL
●   Start the service
●   Check whether or not the service has been started
The MySQL monitor
●   To connect or log on to a MySQL database 
    service:
    $ mysql
●   The MySQL monitor has many options, you can 
    review them using:
    $ man mysql
    or 
    $ mysql ­­help
The MySQL monitor
●   The most important options are:
    $ mysql [options] [database]
     ­u uname | ­­user=uname
      default: UNIX account
     ­p [pwd]| ­­password[=pwd]
      default: <none>
      if pwd not given, prompt for password
     ­h hname | ­­host=hname
      default: localhost
     ­P prt | ­­port=prt
      default: 3306
The MySQL monitor
●   Once connected to the database server, you can 
    execute SQL statements:
    mysql> statement;
●   Every SQL statement should end with a semi­
    colon (;)
Exercises
●   Make sure you do these exercises as a normal 
    UNIX user, and not as root.
●   Connect to the database and execute the 
    following SQL statements:
    mysql> select current_user;
    mysql> show databases;
●   Connect to the databases as user root and execute 
    the same statements.
●   Do you understand the (security) implications?
Securing the server
●   The process of securing the server is automated 
    by running the script
    # mysql_secure_installation
    as root:
    –   Changes the root password
    –   Removes anonymous users
    –   Disallows remote root logins
    –   Removes the test database
Securing the server
●   As an extra precaution, we will prevent any 
    external access to the database server. This is 
    done by putting the following line in the global 
    config file (/etc/mysql/my.cnf) (*):
    [mysqld]
    bind­address = 127.0.0.1
●   After restarting the MySQL service, verify with
    # netstat ­ltpn | grep mysql
    tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1228/mysqld

●   (*) On standard MySQL installations, the global 
    config file is /etc/my.cnf
Exercises
●   Secure your MySQL installation
●   Repeat the last exercise:
    –   it is no longer possible to log in with your ordinary 
        UNIX account ­ why ?
    –   you can still login as root, but with a twist...
Database Users
●   In principle, database users and OS users are 
    completely independent from each other:
    –   If no user is specified when executing mysql, 
        the OS user is taken
    –   The database superadmin is called root@localhost
        This user can do anything, including dropping 
        databases
●   It is not a good idea to always connect to the DB 
    as root. Try to log in as a less privileged user as 
    much as possible.
Database Users
●   To create a database user, connect to the database 
    server as root and issue the following statement:
    mysql> create user dbuser[@host]
           [identified by 'passwd'];
●   In this statement is:
    –   dbuser: the user to be created
    –   host: the hostname from which the user is going to 
        connect ­ if not specified the user can connect from 
        any host (%)
    –   passwd: the password needed to connect to the 
        database server
Exercises
●   Create a database user:
    –   the database user has the same name as your UNIX 
        account
    –   the hostname is localhost
    –   you are free to choose the password
●   Try to connect as this user and execute the 
    following SQL statements:
    mysql> select current_user;
    mysql> show databases;
The options file
●   To avoid having to type your password every 
    time you connect to the database service, you can 
    create an options file:
    –   the file name is .my.cnf
    –   this file is located in your home directory
    –   since it might contain a password, protect it from 
        preying eyes: mode 600
●   The format of .my.cnf is similar to Windows 
    ini­files: it contains key=value pairs in [sections]
●   In fact, the key=value pairs are provided as 
    (invisible) command line parameters
The options file
●   As an example, the password will be put in an 
    options file.
●   Looking at the command line parameters of 
    mysql (and almost all client applications), the 
    password can be provided as:
    $ mysql ­­password=pwd
●   The options file contents could look like this:
    [client]
    password=pwd
Exercises
●   Create an options file and put the password in
●   Make sure the options file is protected on the OS 
    level
●   Try to connect to the database without specifying 
    a password
Database User Privileges
●   The created user has very limited privileges. To 
    grant privileges prv on table tbl in database db, 
    you need to execute the following statement:
    mysql> grant prv on db.tbl 
                      to user@host;
●   Some convenient wild cards:
    –   To grant all privileges, specify all as prv
    –   To include all databases, specify * as db
    –   To include all tables, specify * as tbl
●   The given database and table names do not have 
    to exist (yet)
Getting Help
●   An extensive help system is available in the 
    MySQL monitor:
    mysql> help
    This gives an overview of commands you can use 
    to customize the output
●   You can get help on any function or statement:
    mysql> help contents
    This shows you the broad topics of available 
    help. You can drill down into any of these topics
Getting Help ­ Demo
●   How to get help for creating users:
    mysql> help
    mysql> help contents
    mysql> help account management
    mysql> help create user

●   How to use less as a pager:
    $ export PAGER=/usr/bin/less
    $ mysql
    mysql> pager
    PAGER set to '/usr/bin/less'

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Mysql Ppt
Mysql PptMysql Ppt
Mysql Ppt
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
MYSQL-Database
MYSQL-DatabaseMYSQL-Database
MYSQL-Database
 
Html hyperlinks
Html hyperlinksHtml hyperlinks
Html hyperlinks
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
wamp.ppt
wamp.pptwamp.ppt
wamp.ppt
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
HTML
HTMLHTML
HTML
 
Sql - Structured Query Language
Sql - Structured Query LanguageSql - Structured Query Language
Sql - Structured Query Language
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Html Presentation
Html PresentationHtml Presentation
Html Presentation
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
Database Systems - Introduction (Chapter 1)
Database Systems - Introduction (Chapter 1)Database Systems - Introduction (Chapter 1)
Database Systems - Introduction (Chapter 1)
 
SQL
SQLSQL
SQL
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Front-end Vs. Back-end Development
Front-end Vs. Back-end DevelopmentFront-end Vs. Back-end Development
Front-end Vs. Back-end Development
 
Streams in Java 8
Streams in Java 8Streams in Java 8
Streams in Java 8
 
Basic introduction to html and php tags
Basic introduction to html and php tagsBasic introduction to html and php tags
Basic introduction to html and php tags
 
Structured query language(sql)ppt
Structured query language(sql)pptStructured query language(sql)ppt
Structured query language(sql)ppt
 

Andere mochten auch

Mysql tutorial commands_part1
Mysql tutorial commands_part1Mysql tutorial commands_part1
Mysql tutorial commands_part1prashob7
 
Mysql Introduction
Mysql IntroductionMysql Introduction
Mysql Introductionhemant meena
 
BITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQLBITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQLBITS
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MYXPLAIN
 

Andere mochten auch (9)

ppt
pptppt
ppt
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
Mysql tutorial commands_part1
Mysql tutorial commands_part1Mysql tutorial commands_part1
Mysql tutorial commands_part1
 
Mysql Introduction
Mysql IntroductionMysql Introduction
Mysql Introduction
 
BITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQLBITS: Introduction to relational databases and MySQL - SQL
BITS: Introduction to relational databases and MySQL - SQL
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6
 
Introduction to MySQL
Introduction to MySQLIntroduction to MySQL
Introduction to MySQL
 
Mysql introduction
Mysql introduction Mysql introduction
Mysql introduction
 

Ähnlich wie BITS: Introduction to MySQL - Introduction and Installation

Welcome to MySQL
Welcome to MySQLWelcome to MySQL
Welcome to MySQLGrigale LTD
 
MySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdfMySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdfVinicius M Grippa
 
MySQL Utilities -- PyTexas 2015
MySQL Utilities -- PyTexas 2015MySQL Utilities -- PyTexas 2015
MySQL Utilities -- PyTexas 2015Dave Stokes
 
Securing your database servers from external attacks
Securing your database servers from external attacksSecuring your database servers from external attacks
Securing your database servers from external attacksAlkin Tezuysal
 
Get mysql clusterrunning-windows
Get mysql clusterrunning-windowsGet mysql clusterrunning-windows
Get mysql clusterrunning-windowsJoeSg
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAsFromDual GmbH
 
The Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL DatabasesThe Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL DatabasesDave Stokes
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQLMydbops
 
My sql introduction for Bestcom
My sql introduction for BestcomMy sql introduction for Bestcom
My sql introduction for BestcomIvan Tu
 
My S Q L Introduction for 1 day training
My S Q L  Introduction for 1 day trainingMy S Q L  Introduction for 1 day training
My S Q L Introduction for 1 day trainingIvan Tu
 
My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)Gustavo Rene Antunez
 
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019Dave Stokes
 
Mysql wp cluster_quickstart_windows
Mysql wp cluster_quickstart_windowsMysql wp cluster_quickstart_windows
Mysql wp cluster_quickstart_windowsRogério Rocha
 

Ähnlich wie BITS: Introduction to MySQL - Introduction and Installation (20)

Mysql all
Mysql allMysql all
Mysql all
 
Mysql all
Mysql allMysql all
Mysql all
 
Welcome to MySQL
Welcome to MySQLWelcome to MySQL
Welcome to MySQL
 
MySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdfMySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdf
 
MySQL Utilities -- PyTexas 2015
MySQL Utilities -- PyTexas 2015MySQL Utilities -- PyTexas 2015
MySQL Utilities -- PyTexas 2015
 
Introduction Mysql
Introduction Mysql Introduction Mysql
Introduction Mysql
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
Securing your database servers from external attacks
Securing your database servers from external attacksSecuring your database servers from external attacks
Securing your database servers from external attacks
 
Mysql tutorial 5257
Mysql tutorial 5257Mysql tutorial 5257
Mysql tutorial 5257
 
Get mysql clusterrunning-windows
Get mysql clusterrunning-windowsGet mysql clusterrunning-windows
Get mysql clusterrunning-windows
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
The Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL DatabasesThe Proper Care and Feeding of MySQL Databases
The Proper Care and Feeding of MySQL Databases
 
Mysql ppt
Mysql pptMysql ppt
Mysql ppt
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQL
 
My sql introduction for Bestcom
My sql introduction for BestcomMy sql introduction for Bestcom
My sql introduction for Bestcom
 
My S Q L Introduction for 1 day training
My S Q L  Introduction for 1 day trainingMy S Q L  Introduction for 1 day training
My S Q L Introduction for 1 day training
 
My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)
 
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
MySQL Baics - Texas Linxufest beginners tutorial May 31st, 2019
 
MySQL database
MySQL databaseMySQL database
MySQL database
 
Mysql wp cluster_quickstart_windows
Mysql wp cluster_quickstart_windowsMysql wp cluster_quickstart_windows
Mysql wp cluster_quickstart_windows
 

Mehr von BITS

RNA-seq for DE analysis: detecting differential expression - part 5
RNA-seq for DE analysis: detecting differential expression - part 5RNA-seq for DE analysis: detecting differential expression - part 5
RNA-seq for DE analysis: detecting differential expression - part 5BITS
 
RNA-seq for DE analysis: extracting counts and QC - part 4
RNA-seq for DE analysis: extracting counts and QC - part 4RNA-seq for DE analysis: extracting counts and QC - part 4
RNA-seq for DE analysis: extracting counts and QC - part 4BITS
 
RNA-seq for DE analysis: the biology behind observed changes - part 6
RNA-seq for DE analysis: the biology behind observed changes - part 6RNA-seq for DE analysis: the biology behind observed changes - part 6
RNA-seq for DE analysis: the biology behind observed changes - part 6BITS
 
RNA-seq: analysis of raw data and preprocessing - part 2
RNA-seq: analysis of raw data and preprocessing - part 2RNA-seq: analysis of raw data and preprocessing - part 2
RNA-seq: analysis of raw data and preprocessing - part 2BITS
 
RNA-seq: general concept, goal and experimental design - part 1
RNA-seq: general concept, goal and experimental design - part 1RNA-seq: general concept, goal and experimental design - part 1
RNA-seq: general concept, goal and experimental design - part 1BITS
 
RNA-seq: Mapping and quality control - part 3
RNA-seq: Mapping and quality control - part 3RNA-seq: Mapping and quality control - part 3
RNA-seq: Mapping and quality control - part 3BITS
 
Productivity tips - Introduction to linux for bioinformatics
Productivity tips - Introduction to linux for bioinformaticsProductivity tips - Introduction to linux for bioinformatics
Productivity tips - Introduction to linux for bioinformaticsBITS
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsBITS
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsBITS
 
Managing your data - Introduction to Linux for bioinformatics
Managing your data - Introduction to Linux for bioinformaticsManaging your data - Introduction to Linux for bioinformatics
Managing your data - Introduction to Linux for bioinformaticsBITS
 
Introduction to Linux for bioinformatics
Introduction to Linux for bioinformaticsIntroduction to Linux for bioinformatics
Introduction to Linux for bioinformaticsBITS
 
BITS - Genevestigator to easily access transcriptomics data
BITS - Genevestigator to easily access transcriptomics dataBITS - Genevestigator to easily access transcriptomics data
BITS - Genevestigator to easily access transcriptomics dataBITS
 
BITS - Comparative genomics: the Contra tool
BITS - Comparative genomics: the Contra toolBITS - Comparative genomics: the Contra tool
BITS - Comparative genomics: the Contra toolBITS
 
BITS - Comparative genomics on the genome level
BITS - Comparative genomics on the genome levelBITS - Comparative genomics on the genome level
BITS - Comparative genomics on the genome levelBITS
 
BITS - Comparative genomics: gene family analysis
BITS - Comparative genomics: gene family analysisBITS - Comparative genomics: gene family analysis
BITS - Comparative genomics: gene family analysisBITS
 
BITS - Introduction to comparative genomics
BITS - Introduction to comparative genomicsBITS - Introduction to comparative genomics
BITS - Introduction to comparative genomicsBITS
 
BITS - Protein inference from mass spectrometry data
BITS - Protein inference from mass spectrometry dataBITS - Protein inference from mass spectrometry data
BITS - Protein inference from mass spectrometry dataBITS
 
BITS - Overview of sequence databases for mass spectrometry data analysis
BITS - Overview of sequence databases for mass spectrometry data analysisBITS - Overview of sequence databases for mass spectrometry data analysis
BITS - Overview of sequence databases for mass spectrometry data analysisBITS
 
BITS - Search engines for mass spec data
BITS - Search engines for mass spec dataBITS - Search engines for mass spec data
BITS - Search engines for mass spec dataBITS
 
BITS - Introduction to proteomics
BITS - Introduction to proteomicsBITS - Introduction to proteomics
BITS - Introduction to proteomicsBITS
 

Mehr von BITS (20)

RNA-seq for DE analysis: detecting differential expression - part 5
RNA-seq for DE analysis: detecting differential expression - part 5RNA-seq for DE analysis: detecting differential expression - part 5
RNA-seq for DE analysis: detecting differential expression - part 5
 
RNA-seq for DE analysis: extracting counts and QC - part 4
RNA-seq for DE analysis: extracting counts and QC - part 4RNA-seq for DE analysis: extracting counts and QC - part 4
RNA-seq for DE analysis: extracting counts and QC - part 4
 
RNA-seq for DE analysis: the biology behind observed changes - part 6
RNA-seq for DE analysis: the biology behind observed changes - part 6RNA-seq for DE analysis: the biology behind observed changes - part 6
RNA-seq for DE analysis: the biology behind observed changes - part 6
 
RNA-seq: analysis of raw data and preprocessing - part 2
RNA-seq: analysis of raw data and preprocessing - part 2RNA-seq: analysis of raw data and preprocessing - part 2
RNA-seq: analysis of raw data and preprocessing - part 2
 
RNA-seq: general concept, goal and experimental design - part 1
RNA-seq: general concept, goal and experimental design - part 1RNA-seq: general concept, goal and experimental design - part 1
RNA-seq: general concept, goal and experimental design - part 1
 
RNA-seq: Mapping and quality control - part 3
RNA-seq: Mapping and quality control - part 3RNA-seq: Mapping and quality control - part 3
RNA-seq: Mapping and quality control - part 3
 
Productivity tips - Introduction to linux for bioinformatics
Productivity tips - Introduction to linux for bioinformaticsProductivity tips - Introduction to linux for bioinformatics
Productivity tips - Introduction to linux for bioinformatics
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformatics
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformatics
 
Managing your data - Introduction to Linux for bioinformatics
Managing your data - Introduction to Linux for bioinformaticsManaging your data - Introduction to Linux for bioinformatics
Managing your data - Introduction to Linux for bioinformatics
 
Introduction to Linux for bioinformatics
Introduction to Linux for bioinformaticsIntroduction to Linux for bioinformatics
Introduction to Linux for bioinformatics
 
BITS - Genevestigator to easily access transcriptomics data
BITS - Genevestigator to easily access transcriptomics dataBITS - Genevestigator to easily access transcriptomics data
BITS - Genevestigator to easily access transcriptomics data
 
BITS - Comparative genomics: the Contra tool
BITS - Comparative genomics: the Contra toolBITS - Comparative genomics: the Contra tool
BITS - Comparative genomics: the Contra tool
 
BITS - Comparative genomics on the genome level
BITS - Comparative genomics on the genome levelBITS - Comparative genomics on the genome level
BITS - Comparative genomics on the genome level
 
BITS - Comparative genomics: gene family analysis
BITS - Comparative genomics: gene family analysisBITS - Comparative genomics: gene family analysis
BITS - Comparative genomics: gene family analysis
 
BITS - Introduction to comparative genomics
BITS - Introduction to comparative genomicsBITS - Introduction to comparative genomics
BITS - Introduction to comparative genomics
 
BITS - Protein inference from mass spectrometry data
BITS - Protein inference from mass spectrometry dataBITS - Protein inference from mass spectrometry data
BITS - Protein inference from mass spectrometry data
 
BITS - Overview of sequence databases for mass spectrometry data analysis
BITS - Overview of sequence databases for mass spectrometry data analysisBITS - Overview of sequence databases for mass spectrometry data analysis
BITS - Overview of sequence databases for mass spectrometry data analysis
 
BITS - Search engines for mass spec data
BITS - Search engines for mass spec dataBITS - Search engines for mass spec data
BITS - Search engines for mass spec data
 
BITS - Introduction to proteomics
BITS - Introduction to proteomicsBITS - Introduction to proteomics
BITS - Introduction to proteomics
 

Kürzlich hochgeladen

4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataBabyAnnMotar
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxDhatriParmar
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 

Kürzlich hochgeladen (20)

4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
Measures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped dataMeasures of Position DECILES for ungrouped data
Measures of Position DECILES for ungrouped data
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptxMan or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
Man or Manufactured_ Redefining Humanity Through Biopunk Narratives.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 

BITS: Introduction to MySQL - Introduction and Installation

  • 1. Introduction to MySQL ● Introduction ● Installation ● SQL ● Schema design ● Perl BITS/VIB Bioinformatics Training – Jun 24, 2011 – Luc Ducazu <luc@daphnia.com>
  • 2.
  • 3. Introduction to MySQL ● Introduction ● Installation ● SQL ● Schema design ● Perl BITS/VIB Bioinformatics Training – Jun 24, 2011 – Luc Ducazu <luc@daphnia.com>
  • 4. Databases ● A database is a collection of data – numbers – dates – text or labels – … ● A Database Management System – Data storage – Data retrieval – Data manipulation – Authentication & Authorization
  • 5. Relational Databases ● Rigid structure ● 2 dimensional tables:  – columns (fields) – rows (records)
  • 6. Relational Databases ● Model objects (entities) and their relationships ● Eg a store sells products to customers – Entities: ● Customers Attributes: name, address, telephone number... ● Products  Attributes: name, price... – Relationships: ● Sale Attributes: quantity, timestamp...
  • 7. Relational Databases ● MySQL Workbench: – graphical representation of entities and relationships – generates SQL statements to create database & tables
  • 8. Relational Database Management  Systems (RDBMS) ● Enforce data intergrity: Honors constraints on columns ● Enforce referential integrity: Honors constraints on relations ● See also: the 12 rules of Edgar Codd http://en.wikipedia.org/wiki/Codd%27s_12_rules
  • 9. RDBMS ● Commercial products: – Oracle – DB2 (IBM) – MS SQL Server (Microsoft) ● Open­source offerings: – MySQL (Oracle) Forks: ● MariaDB ● Drizzle – PostgreSQL – SQLite
  • 10. NoSQL ● Key­value stores – Berkeley DB ● Document databases – unstructured data – CouchDB – MongoDB – Cassandra (FaceBook) ● See also:  http://en.wikipedia.org/wiki/Nosql
  • 11. Introduction to MySQL ● Introduction ● Installation ● SQL ● Schema design ● Perl BITS/VIB Bioinformatics Training – Jun 24, 2011 – Luc Ducazu <luc@daphnia.com>
  • 12. Installing MySQL on Linux ● For DEB based Linux distributions (Debian, Ubuntu, …) # apt­get install mysql­server ● For RPM based Linux distributions (RHEL, Fedora, CentOS, ...) # yum install mysql­server
  • 13. Installing MySQL on Windows ● An installable (MSI) package is available on the  MySQL site: http://www.mysql.com/ – Follow the 'Downloads (GA)' link – Choose 'MySQL Community Server' – Select 'Microsoft Windows' as platform
  • 14. Running MySQL ● To start / stop / restart the MySQL service: # service mysql start # service mysql stop # service mysql restart ● When starting MySQL for the first time, the  system administrator is reminded that the MySQL  setup is not yet secured
  • 15. Running MySQL ● To check whether or not mysql is running  correctly: # service mysql status mysql start/running, process 3394 # ps ­ef | grep mysql mysql  3394  1  0 12:09 ?  00:00:00  /usr/sbin/mysqld # netstat ­ltpn | grep mysql tcp 0 0  0.0.0.0:3306  0.0.0.0:*  LISTEN  3394/mysqld 
  • 16. Exercises ● Install MySQL ● Start the service ● Check whether or not the service has been started
  • 17. The MySQL monitor ● To connect or log on to a MySQL database  service: $ mysql ● The MySQL monitor has many options, you can  review them using: $ man mysql or  $ mysql ­­help
  • 18. The MySQL monitor ● The most important options are: $ mysql [options] [database]  ­u uname | ­­user=uname default: UNIX account  ­p [pwd]| ­­password[=pwd] default: <none> if pwd not given, prompt for password  ­h hname | ­­host=hname default: localhost  ­P prt | ­­port=prt default: 3306
  • 19. The MySQL monitor ● Once connected to the database server, you can  execute SQL statements: mysql> statement; ● Every SQL statement should end with a semi­ colon (;)
  • 20. Exercises ● Make sure you do these exercises as a normal  UNIX user, and not as root. ● Connect to the database and execute the  following SQL statements: mysql> select current_user; mysql> show databases; ● Connect to the databases as user root and execute  the same statements. ● Do you understand the (security) implications?
  • 21. Securing the server ● The process of securing the server is automated  by running the script # mysql_secure_installation as root: – Changes the root password – Removes anonymous users – Disallows remote root logins – Removes the test database
  • 22. Securing the server ● As an extra precaution, we will prevent any  external access to the database server. This is  done by putting the following line in the global  config file (/etc/mysql/my.cnf) (*): [mysqld] bind­address = 127.0.0.1 ● After restarting the MySQL service, verify with # netstat ­ltpn | grep mysql tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1228/mysqld ● (*) On standard MySQL installations, the global  config file is /etc/my.cnf
  • 23. Exercises ● Secure your MySQL installation ● Repeat the last exercise: – it is no longer possible to log in with your ordinary  UNIX account ­ why ? – you can still login as root, but with a twist...
  • 24. Database Users ● In principle, database users and OS users are  completely independent from each other: – If no user is specified when executing mysql,  the OS user is taken – The database superadmin is called root@localhost This user can do anything, including dropping  databases ● It is not a good idea to always connect to the DB  as root. Try to log in as a less privileged user as  much as possible.
  • 25. Database Users ● To create a database user, connect to the database  server as root and issue the following statement: mysql> create user dbuser[@host]        [identified by 'passwd']; ● In this statement is: – dbuser: the user to be created – host: the hostname from which the user is going to  connect ­ if not specified the user can connect from  any host (%) – passwd: the password needed to connect to the  database server
  • 26. Exercises ● Create a database user: – the database user has the same name as your UNIX  account – the hostname is localhost – you are free to choose the password ● Try to connect as this user and execute the  following SQL statements: mysql> select current_user; mysql> show databases;
  • 27. The options file ● To avoid having to type your password every  time you connect to the database service, you can  create an options file: – the file name is .my.cnf – this file is located in your home directory – since it might contain a password, protect it from  preying eyes: mode 600 ● The format of .my.cnf is similar to Windows  ini­files: it contains key=value pairs in [sections] ● In fact, the key=value pairs are provided as  (invisible) command line parameters
  • 28. The options file ● As an example, the password will be put in an  options file. ● Looking at the command line parameters of  mysql (and almost all client applications), the  password can be provided as: $ mysql ­­password=pwd ● The options file contents could look like this: [client] password=pwd
  • 29. Exercises ● Create an options file and put the password in ● Make sure the options file is protected on the OS  level ● Try to connect to the database without specifying  a password
  • 30. Database User Privileges ● The created user has very limited privileges. To  grant privileges prv on table tbl in database db,  you need to execute the following statement: mysql> grant prv on db.tbl                    to user@host; ● Some convenient wild cards: – To grant all privileges, specify all as prv – To include all databases, specify * as db – To include all tables, specify * as tbl ● The given database and table names do not have  to exist (yet)
  • 31. Getting Help ● An extensive help system is available in the  MySQL monitor: mysql> help This gives an overview of commands you can use  to customize the output ● You can get help on any function or statement: mysql> help contents This shows you the broad topics of available  help. You can drill down into any of these topics
  • 32. Getting Help ­ Demo ● How to get help for creating users: mysql> help mysql> help contents mysql> help account management mysql> help create user ● How to use less as a pager: $ export PAGER=/usr/bin/less $ mysql mysql> pager PAGER set to '/usr/bin/less'