MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf ·...

52
© All rights reserved. Zend Technologies, Inc. Mike Pavlak Solutions Consultant [email protected] (815) 722 3454 Function Junction MySQL for IBM i Or Zend DBi == MySQL!

Transcript of MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf ·...

Page 1: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Mike Pavlak

Solutions Consultant

[email protected]

(815) 722 3454

Function Junction

MySQL for IBM i

Or

Zend DBi == MySQL!

Page 2: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Agenda

• What is MySQL

• Install

• Access

• GUI’s

• DB2 Storage Engine

• Q&A

| 2 02/04/10

Page 3: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

What is MySQL?

• Most Popular and widely used Open Source Database

• Relational Database management System (RDBMS)

• Like DB2, but not, really

• Command line interface

• Many GUI utilities available to manage

| 3 02/04/10

Page 4: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Who uses MySQL & why?

• Millions of downloads

• Big companies

• Growing in IBM i

• Nearly Everyone using open source PHP applications

• Free

• Open Source

• Delivered by Zend

• Back end for thousands of applications like drupal, Sugar

CRM, Media Wiki, etc.

| 4 02/04/10

Page 5: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

How does it work?

• Essentially flat files in the IFS

• MySQL has two major parts:

• UI Layer

• Storage Engine

• MyISAM

• INNODB

• IBMDB2

• Sound familiar?

| 5 02/04/

10

Page 6: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Architecture

Page 7: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

History of MySQL

Page 8: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

| 8 02/04/10

In the beginning

Founded by

David Axmark

Allan Larsson

Michael “Monty” Widenius

Named after Monty’s daughter “My” (Pronounced mee)

Page 9: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Ownership

Remember MySQL is Open Source: Anyone can compile the

source code and use the binaries as long as they follow the

rules of the license.

Jan 2008:Sun purchased MySQL for $1B

Oracle purchased sun about year later for $7.4B

FUD ensues…

Today, MySQL contiues to live on

Page 10: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

What about IBM i? Zend DBI == MySQL

A few years ago Oracle dropped support for MySQL on Power

and discontinued compiling the binaries.

Old binaries still available on Oracle archive site

IBM began looking for a new suitor

Zend stepped up and took over the binary distribution for

MySQL for IBM i and the new product is called Zend DBi

Same wonderful MySQL, just compiled for POWER IBM i

Available for no charge at www.zend.com/products/dbi

Page 11: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Installation, Zend DBi

Page 12: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

MySQL Options

• If you have never installed MySQL or Zend DBi

• Perform a clean installation of Zend DBi

• Otherwise, if you have MySQL & no real data

• Delete MySQL (Steps on next slide)

• If you have data and are at Version 5.1.x of MySQL

• Update to Zend DBI via the install process

• Lastly, if you have data at a version 5.0.x or lower

• Export data

• Delete MySQL

• Perform clean install of ZendDBi

| 12 02/04/10

Page 13: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Details on deleting MySQL

• Steps for a clean removal…

• ENDSBS ZMYSQL OPTION(*IMMED)

• DLTLIB ZMYSQL

• CALL QP2TERM

• rm -f /usr/local/mysql

• rm -r -f /usr/local/mysql-5.1.50-i5os-power-64bit

• rm -r -f /usr/local/mysqldata

• rm -f /etc/my.cnf

• rm -f /tmp/mysql.sock

| 13 02/04/10

Page 14: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Zend DBi Installation process

• Documented at Zend.com

• Option to install or update within point release

• Can update 5.1.x to 5.1.y (Zend Server)

• Cannot update 5.0.x to 5.1.y (Zend Core)

• Download .zip from Zend.com, contains SAVF & README

• Follow readme.txt in SAVF, pretty straight forward

• Required LP’s are typically installed before Zend Server

• A word about QSECOFR…UID = 0

| 14 02/04/10

Page 15: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Update anyone?

• Here we have 5.1.50 (install with ZS 5.1)

• Let’s go up to 5.1.59 (Zend DBi)

| 15 02/04/10

Page 16: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Start the installation process

• Have ROOT password before updating

• Just stop ZMYSQL

• GO ZMYSQL/ZCMYSQL

• Option 5 then Option 2 then exit MySQL menu

| 16 02/04/10

Page 17: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Get SAVF to IBM i

• FTP and check it…

| 17 02/04/10

Page 18: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Start the update process

• Steps to fire up process

• RSTLIB SAVLIB(ZMYSQL)

• CHGCURLIB ZMYSQL

• CALL ZMYSQLUPG1

| 18 02/04/10

Page 19: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Set update options

• Have ROOT password before you get here

• Will run MySQL script to update!

| 19 02/04/10

Page 20: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Woohoo!

| 20 02/04/10

Page 21: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

New subsystem and daemon

• ZENDDBI

• ZENDDBID

| 21 02/04/10

Page 22: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

MySQL Command Line

Page 23: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

MySQL Monitor

• MySQL has no native GUI interface (sound familiar?)

• Command line accessible from QSHELL, QP2TERM, etc.

• This is the natural method for accessing.

• Will show you access, but not a big fan.

• Fully documented at MySQL website

• Many books on the subject

| 23 02/04/10

Page 24: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Starting MySQL Monitor

• I typically use CALL QP2TERM, can use QSH, etc.

• The mysql> is the prompter for the monitor

• Mysql –u root

• Mysql –u root –p mikey

| 24 02/04/10

Page 25: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Difference between QP2TERM and Qshell

• QP2TERM is window to PASE

• Cannot run IBM native programs like DB2, etc.

• Qshell is a Unix like shell

• Runs many things you find on Unix and IBM binaries

| 25 02/04/10

Qshell Call QP2TERM

Page 26: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

List all the databases

• Show databases;

• List all databases in MySQL

• Database is like a library

• Usually sorted by application

| 26 02/04/10

Don’t forget the semi-colon!

Page 27: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Set database

•Use <DBNAME>

• Selects the database you will use for processing

• Database is like a library, where you store

tables, etc.

• Typically one database per application

| 27 02/04/10

Page 28: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

List tables

| 28 02/04/10

Page 29: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Display the user table

| 29 02/04/10

• Use SQL: select host, user, password from user;

• Use “quit” to end the session in the MySQL Monitor and F3 to close shell.

Page 30: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Are there any GUI’s?

Page 31: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Many GUI solutions

Adminer

Single PHP script

Lightweight, powerful and easy to use

phpMyAdmin

Widely used by community

Installed with Zend Server

Page 32: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Adminer

Page 33: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

phpMyAdmin

• Open Source PHP Project

• Provides nearly every access to MySQL you might need

• Installed automatically with Zend Server.

• Access from Zend Server Dashboard…

• Documentation at

http://www.phpmyadmin.net/documentation/

| 33 02/04/10

Page 34: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

phpMyAdmin

• Login with “root” profile

• Create your profile

• Test your profile

• Change root password

IMMEDIATELY (if not sooner)

| 34 02/04/10

Page 35: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Tour the dashboard..then on to privileges

| 35 02/04/10

Page 36: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

phpMyAdmin

• Login with “root” profile

• Create your profile

• Test your profile

• Change root password

IMMEDIATELY (if not sooner)

| 36 02/04/10

Page 37: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Privileges

• Click Add new user

• Fill out details, click GO

| 37 02/04/10

Page 38: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Look at databases & tables

• Left hand navigation

• Right hand workspace

• FULL CRUD capabilities

• Think DFU for MySQL!

| 38 02/04/10

Page 39: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

IBM DB2 Storage

Engine

Page 40: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Why use MySQL to store in DB2?

Many PHP applications in the open source arena

Can be easily installed

Modifying to access DB2 can be cumbersome & then updates?

Zend DBi includes IBM DB2 Storage Engine

Page 41: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Architecture

Page 42: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

How to install

From the MySQL Monitor in QSH or QP2TERM

Now go to phpMyAdmin and select the engine

Instruction is in Install Notes for ZendDBi and IBM Redbooks

Page 43: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

IBM DB2 Storage Engine:phpMyAdmin

Create Table, set number of fields

Select storage engine

Page 44: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

phpMyAdmin gives you the SQL!

Page 45: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Add records to table

Page 46: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

What happened on the i?

Library test was created

Table was created

Records populated

Page 47: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Records, please?

STRSQL

Select * from test/exampleDB2

Page 48: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Wrap it up!

Page 49: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

IBM Redbook and Redpiece

Discovering MySQL Using the DB2 Storage Engine

Page 51: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc.

Join us at ZendCon The premier PHP conference!

October 22-25, 2012 – Santa Clara, CA

www.zendcon.com

Conference Themes

PHP in 2012 - The latest PHP technologies and tools Learn how to leverage the latest mobile, HTML 5, testing and PHP best practices

Zend Framework 2 - Hit the ground running Learn how to build faster, more modular and more expandable applications

Development & The Cloud – A love story Learn how the latest developments in cloud-based services, infrastructure and best practices can benefit you

Conference Highlights

• Sessions focused on how to best develop and deploy PHP

• Sessions designed for all knowledge levels

• Intensive tutorials for accelerated learning

• PHP Certification crash courses and testing

• Exhibit hall showcasing the latest products

• Special networking opportunities during meals and events

Page 52: MySQL for IBM i Or Zend DBi == MySQL!static.zend.com/topics/Introduction-to-MySQL-20120816.pdf · MySQL for IBM i Or Zend DBi == MySQL! © All rights reserved. Zend Technologies,

© All rights reserved. Zend Technologies, Inc. 52 Insert->Header & Footer

Q&A

www.zend.com

[email protected]