Wednesday, April 20, 2011

Where the MySQL Users Conference Should Consider Going

The MySQL Users Conference and the Oracle Collaborate Conference both finished last week.   Since that time there has been a pretty significant bitstream discussing where the MySQL Users Conference should go and what is it's future.  Here are a few insights and overviews of MySQL Users Conference:

Data in the Cloud - Marten Mickos - A perspective on where open source databases are going.

The MySQL user community is strong but it now has a lot of different leaders with different perspectives.   Can the MySQL user community generate enough leadership as a community to together take the MySQL users conference further?  Especially since this user community is very independent by nature. 

I believe the MySQL user community should consider trying to become the 4th spoke at the Collaborate 2012 Conference and be the open source section of the conference.  Or to try partnering with the IOUG in increasing the IOUG technical presentations with a large open source section.  It seems like the developers are going to want to have access to the different databases surrounding open source, so it is in the best interest of the open source user community to consider what is best for the group.

It will be interesting to see how the MySQL user community evolves in the next year.

Thursday, February 10, 2011

MySQL Growing Faster in the Cloud

It's been amazing to see the growth of MySQL in the cloud.  I'm seeing more customers moving to cloud providers that are offering MySQL platforms running in Virtual Machines.  It's interesting to see the way the cloud providers are configuring and delivering the platforms.  Virtualization is going to continue to be the deployment method for the delivering of systems in the cloud.  There is currently an evolution of best practices as databases are getting deployed in the cloud.

Saturday, October 23, 2010

MySQL Most Popular Database and Growing

The great thing about Open Source is that despite proprietary vendors best efforts, they can't control the market for open source.  When I first joined MySQL AB years ago, industry analysts estimated there were over 12 million MySQL database servers running.  Which is why MySQL has been considered the most popular database.  Now conservative estimates are now at 80 million MySQL database servers running.

MySQL is also the most popular database for the cloud.   All major efforts you see from companies like Amazon and Google, are all supporting MySQL as the database engine behind the cloud.  Companies are seeing that if it works for some of the biggest Cloud companies in the world, it can work for them also.  A friend of mine (Tom) refers to MySQL as the "secret sauce" of the Internet and the Cloud.  I couldn't agree more.

Sunday, September 19, 2010

MySQL Sunday at Oracle Open World 2010

MySQL Sunday is an open series and looks like a great start to the Oracle Open World conference.  Everyone is waiting to see if there are any announcements for MySQL at the conference from Oracle.  I like that they are starting with Edward Scriven and closing with Marten Mickos.  Hopefully there will be a lot of questions answered on stated directions and the MySQL 5.5 release and product updates.

List of key events in the opening Sunday series include:

  • What's Next for MySQL? Edward Scriven
  • InnoDB Enhancements and Roadmap
  • Performance and Scalability in MySQL 5.5
  • Advanced MySQL Replication Techniques
  • MySQL Closing Session - Marten Mickos

I won't be able to attend the presentation but Sarah Sproehnle's Cloudera presentation looks to be a great one to attend also.

Thursday, August 19, 2010

MySQL at Oracle Open World - San Francisco 2010

Everybody is very interested in understanding the Oracle message about MySQL.  Oracle is responding with a "MySQL Sunday"   and a number of excellent presentations throughout the week in San Francisco at Oracle Open World.  My session on MySQL is:
  • Session S316920 - The Ultimate Bootstrap for MySQL on Windows
There are also a number of excellent old MySQLers and friends presenting like:
  • Sarah Sproehnle - Cloudera
  • Brian Miezejewski - Oracle
  • Harrison Fisk - Facebook
  • Giuseppe Maxia - Oracle
  • Lars Thalmann - Oracle
  • Chris Schneider - Ning
  • Mark Matthews - Oracle
  • Sheeri Cabral - Pythian Group
It's looking like a good layout for Oracle Open World.   So it's going to be good to see how things go from a MySQL perspective and how that projects into the next IOUG Collaborate Conference 2011 in Orlando. 

Wednesday, July 21, 2010

MySQL and Open Source at Oracle Open World

Oracle Open World is fast approaching.   I am definitely looking forward to the MySQL and open source activity at the upcoming Oracle Open World conference in San Francisco.   I'm scheduled to deliver a presentation on implementing MySQL on Windows.   I am also looking forward to Oracle's first Open World conference with MySQL under the Oracle family umbrella.

Tuesday, April 13, 2010

MYSQL 5.5 highlights and MySQL Cluster 7.1

MySQL 5.5 Highlights - It's a lot faster!
  • InnoDB
    • Multiple Buffer Pool Instances
    • Multiple Rollback Segments
    • Extended change buffering and purge scheduling
    • Improved Log Sys and Flush List mutex
    • Improved locking
    • Improved statistics on InnoDB mutexes, rw-locks, threads and I/O operations.
  • Improved performance/scale with Win32, 64
  • Scales to 32 cores 
  • Semi-synchronoous replication
  • Performance Schema
  • SIGNAL/RESIGNAL (finally!)
  • New Partitioning enhancements
  • Configuring the heartbeat period
  • More than 10x improvement in recovery times
  • 200% performance gain for MySQL 5.5 over 5.1.40
MySQL Cluster 7.1 (GA)
  • NDBINFO - improved real time status and usage statistics
  • MYSQL Cluster Manager (CGE only)
  • Sub-second failover and self healing recovery
  • Parallel multi-master architecture
  • Low latency - real time responsiveness
Additional links:

    MySQL Users Conference 2010









    Since the Sun acquisition and the following announcement of the Oracle acquisition, the owner of MySQL have been fairly silent in terms of stated directions of MySQL.   This has allowed a lot of FUD to be spread throughout the user community.  At the MySQL users conference there are going to be some excellent keynotes helping customers get an update on MySQL technology.  It will be very interesting to see how the mind share of the user community is influenced by the keynotes this week.  We can also expect in the future the Independent Oracle Users Group (IOUG) which is the Oracle technology user group for DBAs, Unix Administrators and Developers increases its involvement with MySQL  Then at Oracle Open World this fall we can also expect an more activity with MySQL and updates on the MySQL technology areas.

    There was a lot of internal discussions on the vendor attendance, the mood and feel of the conference compared to last year, overall attendance and who is capturing the mind share of MySQL customers, developers and DBAs.  Internal discussions by dolphins were also very, very interesting.  It also appears that the maturity and popularity of MySQL has it breaking into different versions similar to how Unix separated into different derivatives back in the old days.

    After Conference Links:

    Conference Keynotes::

    Tuesday, April 13

    8:30am - 9:15am
    State of the Dolphin Edward Screven

    Highlights include MySQL 5.5 performance gains, MySQL Cluster 7.1, MySQL Enterprise Monitor enhancements and Oracle's LAMP stack.

    9:15 - 10:00   Tim O'Reilly - Insights on cloud services, mobile devices, future.  radar.oreilly.com may find interest.  "Internet is really a data operating system".

    Wednesday, April 14  Brian and Monty's keynotes are on two different visions of the MySQL and open source future.

    8:30am - 9:15am
    State of Drizzle  Brian Aker

    SQLite ubiquitous with embedded devices.
    In two years SSD is going to be the common device
    Why spend $3000 on consulting and instead spend $500 on a SSD device.
    Drizzle removes a lot of unneeded features (bloat) in MySQL.
    There will be no "Drizzle Inc/" for this MySQL fork.  There will be people and companies who provide services around it.

    They removed locks, go to lockless designs.

    Future will have many core systems.
    College students learning OO so C++ more important the C.
    Drizzle - C++, Booth, SDL?
    They have one blog type, don't use 3 byte integer.
    Web is UTF-8. not Swedish, etc.
    Drizzle 64bit, SSD, highly multicore, use external libraries, use C++/STL/Boost
    Every two weeks a new release of drizzle.  They use launch pad.  All source code is there.
    Everything is open source.
    No table level locks.
    Data dictionary is federated. No .frm file, no corruption in this case. Don't' want storage engine out of synch.

    Highlights.  80+ code contributors within two years.   This is never happened in two years at MySQL.
    4 companies with core developers.
    They have no warnings with GCC. If its a warning, its an error.   Compiler is usually right.

    Status of Drizzle today:
    Default Engine has been transactional for over a year and passes all test cases.
    Upgrades still require reload.
    Replication is still under testing.

    Presentation had vision, passion and a lot of interesting perspectives.  Vision was very well received by attending audience.

    9:15am - 10:00am
    State of MariaDB Michael Widenius
    Drizzle - is the only true fork.  It won't be backward compatible with MySQL.
    Maria is the glue that will put everything together.
    Maria - MySQL descendants and cousins
    Widenius announced an all-you-can-eat MariaDBa  support model from Monty
    Progam Ab: $36,000 for unlimited, company wide support for MySQL 3.3 upwards.
    The next version of MariaDB is 5.2, will add transactional storage engines - Spider and Spinx - group commit and virtual columns.
    MariaDB includes MariaDB, XtraDB and PBXT storage engines.

    Thursday, April 15

    8:30am - 9:15am
    Discussed some history of MySQL. Introduced new MySQL Oracle ACE Directors.
    Presentation slides.

    9:15am - 10:00am    The Engines Of Community  Jono Bacon

    Discussing community.  "People join communities is to have a sense of belonging".
    Talking about the mechanics of community: Communication channels, Structure, Collaboration and Environment.  Don't want to create a community of fiefdoms.  Need to make teams feel important.

    "A shift in thinking and actions of citizens is more vital than a shift of thinking and actions of institutions and formal leaders."  Community leaders need to understand technical work flow.  Important not to over travel.  Democracy does not work in a collaborate environment. Collaborate environments need to be based on meritocracies.
    Author of the "Art of Community". 

    Saturday, February 13, 2010

    The Journey Continues ...

    I was a leader in the Oracle community who joined MySQL two years ago to learn more about the open source world.  The two years at MySQL were fantastic.   The extraordinary camaraderie, spirit and energy of the company was unbelievable.  I worked with some fantastic people and made a number of life time friends.

    On Monday I become a full time employee of Oracle, so I've come full cycle.   Everybody is very excited about the incredible potential of Oracle and Sun and what we are going to accomplish together.   Oracle employees are enthusiastically welcoming Sun and MySQLers into the Oracle family.  

    I am really looking forward to continuing my journey.

    Monday, February 8, 2010

    Ken Jacobs a great advocate of the database user communities

    Ken Jacobs has been a fantastic advocate of the Oracle and MySQL user communites.  I met Ken on the board of the Independent Oracle Users Group (IOUG).  While Ken was the board liasson on the IOUG board, he was always supporting the Oracle user groups and made very important contributions throughout his time on the board and afterwards.  After serving time on the board, Ken was still always available and continued to be a great resource to the user community.

    Ken continued his important contributions in the open source community through his work with InnoDB and MySQL.

    Ken thank you for always being there.  Your contributions made a big difference and continue to be felt today. I was very disappointed that Ken will no longer be serving in role with InnoDB, MySQL and Open Source.


    Take care and thanks for all the great memories.  Your selfless efforts and friendship will always be appreciated.

    Best wishes in all your future endeavors.



    Sunday, February 7, 2010

    Oracle's Commitment to MySQL, MySQL Releases and Development Cycles

    The last few weeks I am still being asked what is going on with Oracle and MySQL and where is MySQL with it's software releases.  So I am going to include some URLs to hopefully answer some of your questions regarding MySQL.

    Oracle's press release on December 14, 2009 regarding MySQL.
    Summary list MySQL software releases. A more detailed list can be found at Lenz grimmer's blog on February 5, 2010.


    You can learn more about MySQL's development cycles at:
    
    

    Tuesday, February 2, 2010

    Configuring the InnoDB Plugin (1.0.6) in MySQL 5.1.43

    Configuring the InnoDB Plugin (1.0.6) is just as easy in the MySQL 5.1.43 release.  There are a few subtle changes in the new release.  Set the following parameters to configure the InnoDB plugin in 5.1.43.  A few notes:

    • Set the PLUGIN_DIR parameter to the location of the plugin libraries.
    • Verify all the libraries listed below are in the PLUGIN_DIR directory.
    • The PLUGIN_LOAD parameter needs to be set properly. Make sure the definition is one line and there are no spaces.

     
     
    my.cnf configuration 
    [mysqld]
    ignore-builtin-innodb
    
    plugin_dir=/opt/mysql/5.1.43/lib/plugin
     
    plugin-load=innodb=ha_innodb_plugin.so
    ;innodb_trx=ha_innodb_plugin.so
    ;innodb_lock_waits=ha_innodb_plugin.so 
    ;innodb_locks=ha_innodb_plugin.so
    ;innodb_cmp=ha_innodb_plugin.so
    ;innodb_cmp_reset=ha_innodb_plugin.so
    ;innodb_cmpmem=ha_innodb_plugin.so
    ;innodb_cmpmem_reset=ha_innodb_plugin.so
     
     
    Verify the new PLUGIN metadata objects are now available. 
    mysql>  SHOW PLUGINS;
     
    Have fun with the new InnoDB Plugin features. :) 

     

    Thursday, January 14, 2010

    Installing MySQL 5.1 on Linux using MOCA

    Introduction
    The following instructions will lay out an installation of MySQL on Linux using the MySQL Optimal Configuration Architecture (MOCA) for someone with fundamental knowledge of MySQL and basic Linux administration skills. MOCA is a set of best practices I put together to lay out a set of guidelines for installing and configuring a MySQL database server.  MOCA is designed for someone with some experience with MySQL, it is not for someone brand new to MySQL.  MOCA is okay if you have a strong database background and good solid Linux skills.

    If you are new to MySQL or to Linux, I recommend using a default install with a  rpm install or use yum to do the install for you. The MySQL default install is recommended for someone new to MySQL or the operating system platform. If the default package install makes more sense for you, then you can stop reading.  This install is for someone wanting to setup a flexible and scalable configuration.  This configuration is for MySQL 5.1.42 and it will work for any 5.1.x install.

    If you are ready to get started you can skip down to the Start the Installation section.   If you scroll to the very bottom of this blog, I have a summary of the specific commands for the setup.  

    A Default Install using RPM or YUM
    The default install with MySQL is great for users new to MySQL. It is simple, requires a few point and clicks and you are up and running. The problem with a default install is that it is designed to be a very simple install and take minimum resources. This simple layout is excellent in its simplicity but it is not how a production server should be set up.  The default install also spreads MySQL files in different locations like /etc, /usr/bin, /usr/local that is not flexible and violates standard best practices for database servers.  The default install is not how an experienced DBA would want to set up a production database environment.

    Why Perform a Manual Install Using a Tar Ball 
    It is much better to be able to control the layout and configuration of the database software for production database environments and for platforms where multiple MySQL servers may be installed in the future.  Defining consistent standards, guidelines and best practices that are flexible and scalable are the key goals of MOCA.
      This install assumes you have a basic understanding of Linux and  MySQL database administration. Oracle DBAs will find this installation very similar to the concepts of the Optimal Flexible Architecture (OFA).
      For experienced MySQL DBAs a manual install is much better. For this purpose I created a best practices configuration and white paper called MOCA (MySQL Optimal Configuration Architecture).  I wanted to call it GOCA (George's Optimal Flexible Architecture) but MOCA seemed to flow better.  MOCA is based on DBA best practices and should be very similar to Oracle, DB2 and SQL Server production DBAs. There are certain fundamental truths about how database servers should be installed, configured and managed. My MOCA whitepaper addresses these fundamental truths. This manual install will follow MOCA standards and conventions.
    Why MOCA? 
    Visit mysql-dba-journey.blogspot.com to get the details of the reasons behind MOCA and why it is based on best practices. There is also an example of installing MySQL on Mac OS that is very similar to a Linux install. A Solaris install using MOCA can be found at blogs.sun.com/georgetrujillo.  MOCA  focuses on:
    1. Separating database software from other software and files.
    2. Separating data and index files, log files for recovery, administration and backup files.
    3. Developing standard naming conventions.
    4. Defines a flexible configuration that can support multiple database servers on same platform.
    5. A consistent configuration for multiple servers and versions of MySQL database software across an enterprise.
    Installation Summary
    This installation looks more complex than it is.  I use this configuration for all  MySQL DBA classes.
    1. Remove old versions of MySQL if they exist.  Setup an operating system (OS) user called "mysql" and the environment for this OS user.
    2. Set up directories and directory permissions for all MySQL data files.
    3. Setup MySQL software and install MySQL software as mysql operating system user (not as root).  Configure the my.cnf configuration file.
    4. Create the mysql database (mysql_install_db) and . Start the mysql database server (mysqld_safe).  
    5. Setup the security environment (mysql_secure_installation)
    6. Test the shutdown and startup of the database server to test the server setup. 

    Start the Installation

    The environment for this installation is:
    • Enterprise Linux downloaded from Oracle's OTN website.  Red Hat, Fedora and CentOS can be used as well.  I chose Enterprise Linux because I like it and it is great for running Oracle and MySQL on same system so I can do ETL and play with the two database servers.  I installed the MySQL tar package (ball) x86/x64 image mysql-5.1.42-linux-x86_64-glibc23.tar.gz. Downloaded from the http:/dev.mysql.com site.
      Before installing MySQL on any platform, make sure there are no previous versions of MySQL preinstalled that were loaded with the OS. Unless you want the older version of MySQL, your life will be much easier if you remove any previous releases that are not being used.
      Read through this installation a few times before starting.
      Note:  I use the # prompt to signify I am performing steps as root and the $ prompt to show I am performing steps as the mysql OS user.
    Look for existing MySQL software
    This install uses MySQL 5.1.42,  although these installation procedures can be used for any 5.1.x installation. Dependent on the version of Linux and your hardware, different packages may need to be installed or removed (old MySQL installations).

    So you can see my Linux environment I ran the following command at the shell.
    # more /etc/redhat-release
    Red Hat Enteprise Linux Server release 5.4 (Tikanga)

    Check to see if MySQL is installed on your current system.
    # grep mysql /etc/passwd
    # rpm -q mysql
    # find /usr/local -name '*mysql*' - print 
    # find /usr/bin -name '*mysql*' - print 
    # find / -name "*mysql*' - print # look everywhere for MySQL installations

    Remove any MySQL old files or packages. Then verify old MySQL files are gone.  If you leave the old MySQL software that is okay, but make sure MySQL is finding your MySQL files and not the old software (prime example, using the /etc/my.cnf file instead of yours).
    # rpm -e mysql

    Downloading MySQL 
    Go to http://dev.mysql.com and find the Downloads tab. Find the distributions and choose the install release you want.  I prefer a manual install so I choose the Linux Tar Packages file mysql-5.1.42-linux-x86_64-glibc23.tar.gz. Select a mirror. On the Select a Mirror page, I choose No thanks, just take me to the downloads!

    Note: Be aware that this MySQL image worked for me with the OS and hardware I was using.  Make sure you have the right image for your environment.  If commands fail because you can't run the mysql executables, you probably have the wrong image for your environment.

    For a separate Centos 5.2 install on different hardware I used this image:
    mysql-5.1.42-linux-i686-icc-glibc23.tar.gz

    For my Linux environment the file downloaded to the /root/Desktop directory.


    Setup the MySQL software 
    The first set of commands are run as the root OS user (# prompt) to set up the environment.    In the /opt/mysql directory unzip and untar the MySQL software and build a symbolic link. This will set up the MYSQL_HOME directory to be in /opt/mysql/5.1.42 location.
    # mkdir -p /opt/mysql

    Copy tar file to /opt/mysql directory and setup up MySQL software.
    # cp /root/Desktop/mysql-5.1.42-linux-x86_64-glibc23.tar.gz /opt/mysql
    # cd /opt/mysql
    # tar zxvf mysql-5.1.42-linux-x86_64-glibc23.tar.gz
    # ln -s mysql-5.1.42-linux-x86_64-glibc23     5.1.42

    Setup the MySQL directory locations.  Here we are going to put all files below the /db01/mysql01 mount point.  The naming pattern mysql01 signifies database storage for a specific MySQL database server in this layout.  I like to put my InnoDB data and log files in their own location.
    # mkdir -p /db01/mysql01
    # cd /db01/mysql01
    # mkdir data binlogs admin backups innodata innologs



    Setup new mysql user if one does not exist.  If a mysql user does exist, set up a password, default shell, default directory, etc.
    No mysql user was found so I added one. Add the mysql group, mysql user, password and home directory.
    # groupadd -g 300 mysql
    # useradd -u 300 -g 300 -d /home/mysql -s /bin/bash -c "MySQL DBA" mysql
    # passwd mysql
    # chown -R mysql:mysql /opt/mysql    /db01/mysql01

    Login and verify the mysql user setup.  From this point, once you login as mysql user, complete the database server as the mysql user and not as the root OS user.

    # su - mysql (or exec login mysql)

    Then define a default profile file using your favorite text editor.  I chose the bash shell.

    --- .bash_profile file ------
    PS1='$PWD: '
    MYSQL_BASE=/opt/mysql
    MYSQL_HOME=/opt/mysql/5.1.42
    export MYSQL_BASE MYSQL_HOME
    PATH=$MYSQL_HOME/bin:$PATH
    --- end of .bash_profile file -------

    Set your environment by sourcing your profile file.
    $ cd $MYSQL_HOME
    $ .   ./.bash_profile

    MySQL Directory Organization 
    A good way to separate MySQL files and software:
    • /opt/mysql/5.1.42             - Symbolic link to software directory location
    • /db01/mysql01/data          - Data directory for MySQL
    • /db01/mysql01/binlogs     - Binary log files location
    • /db01/mysql01/admin       - Administration files location
    • /db01/mysql01/backups    - Backup files location
    • /db01/mysql01/innodata    - InnoDB shared location
    • /db01/mysql01/innologs   - InnoDB transaction logs location

    Before going further


    Double (triple) check all directory paths and permissions.   99.99% of issues with manual installs  are typos in the directory paths, typos in the file names or permission issues with directories.  To common gotchas:
    • Using the wrong binary for your hardware or OS.
    • Search paths find a preinstalled version of mysql that was loaded with the OS.  This command will show you the default search path MySQL uses.
     $ mysqld --help  --verbose | more
     
    When you try to bring up database server, if it defaults to the default areas its because it cannot find a directory or doesn't have permission for directories specified so it will then try the default locations.


    Use a template file in the support-files directory.
    $ cd /opt/mysql/5.1.42
    $ cp support-files/my-small.cnf   my.cnf


    Add the following entries to the my.cnf file in the [mysqld] group. This separates all your dynamic administration files, data files, and binary log files to different locations.
    [mysqld]
    basedir=/opt/mysql/5.1.42
    datadir=/db01/mysql01/data

    log-error=/db01/mysql01/admin/mysql01.err
    pid-file=/db01/mysql01/admin/mysql01.pid
    log-bin=/db01/mysql01/binlogs/mysql01-bin
    innodb_data_home_dir=/db01/mysql01/innodata
    innodb_data_file_path=ibdata01:50M;ibdata02:50M:autoextend:max:2000M
    innodb_log_group_home_dir=/db01/mysql01/innologs
    #-----------------------------------------------------

    I would also recommend changing the parameter thread_stack=128k   to a minimum of 256k.

    Create the mysql database files for the MySQL database server (instance.) This will create the default database schemas and the physical file layer.

    $ cd $MYSQL_HOME
    $ scripts/mysql_install_db --datadir=/db01/mysql01/data  --basedir=$MYSQL_HOME

    Start the MySQL database server pointing to the defined locations.
    $ cd /opt/mysql/5.1.42
    $ bin/mysqld_safe --defaults-file=$MYSQL_HOME/my.cnf  &

    Verify the mysqld background process is running as well as the mysqld_safe monitoring process. The mysqld background process should be up and running.
    $ ps -ef |grep mysql

    Verify you can get into the server.  Initial setup has no passwords.  If this works you have a good server.  The show command should display the mysql, test and information_schema databases.
    $ mysql
    mysql>  show databases;
    mysql>  exit

    Clean up the database server by adding passwords and getting rid of anonymous users.  The MySQL database super user is called root. This step will add a password for this MySQL database user.
    $ cd $MYSQL_HOME
    $ bin/mysql_secure_installation

    Shutdown the MySQL server to verify you can shutdown and startup the MySQL instance.
    $ mysqladmin -uroot -p  shutdown
    $ bin/mysqld_safe --defaults-file= $MYSQL_HOME/my.cnf &

    You're up and running have fun. Once you are comfortable with this configuration layout, you can create a Unix shell script that will automate almost the entire process. With a shell script automation the install takes about five minutes.


    Summary of steps to perform setup
    Below is a summary of steps minus all the text.

    # ---- Steps performed as root OS user. ---------------
    # mkdir -p /opt/mysql
    # cp /root/Desktop/mysql-5.1.42-linux-x86_64-glibc23.tar.gz /opt/mysql
    # cd /opt/mysql
    # tar zxvf mysql-5.1.42-linux-x86_64-glibc23.tar.gz
    # ln -s mysql-5.1.42-linux-x86_64-glibc23.tar.gz     5.1.42

    # mkdir -p /db01/mysql01
    # cd /db01/mysql01
    # mkdir data binlogs admin backups innodata innologs

    # groupadd -g 300 mysql
    # useradd -u 300 -g 300 -d /home/mysql -s /bin/bash -c "MySQL DBA" mysql
    # passwd mysql
    # chown -R mysql:mysql /opt/mysql    /db01/mysql01

    # su - mysql 

    # ---- Steps performed as mysql OS user ---------------
    $ cd $MYSQL_HOME
    $ cp support-files/my-small.cnf   my.cnf

    # Make these additions in my.cnf file below [mysqld]
    #----------------------
    basedir=/opt/mysql/5.1.42
    datadir=/db01/mysql01/data

    log-error=/db01/mysql01/admin/mysql01.err
    pid-file=/db01/mysql01/admin/mysql01.pid
    log-bin=/db01/mysql01/binlogs/mysql01-bin
    innodb_data_home_dir=/db01/mysql01/innodata
    innodb_data_file_path=ibdata01:50M;ibdata02:50M:autoextend:max:2000M
    innodb_log_group_home_dir=/db01/mysql01/innologs
    #---------------------------------------

    $ scripts/mysql_install_db --datadir=/db01/mysql01/data  --basedir=$MYSQL_HOME

    $ bin/mysqld_safe --defaults-file=$MYSQL_HOME/my.cnf &
    $ bin/mysql_secure_installation

    Tuesday, January 12, 2010

    MySQL Conference and Expo 2010

    The  MySQL Users Conference and Expo 2010 scheduled for April 12 - 15, 2010 in Santa Clara is definitely a conference I highly recommend you attend if you can.  The insights, networking and knowledge gained is invaluable.  The fantastic dynamics of the open source community has to be experienced to be understood.  :)

    Saturday, October 24, 2009

    Accessing Metadata through Stored Routines

    Accessing metadata can be optimized by using stored routines.  Stored routines provide the ability to filter the data in a more useful way.  For example, when I'm looking at table data I usually want to look at the index information also.  So I use a stored routine called tabinfo that gives me key information I need for tables and indexes.

    -- Create the tabinfo stored procedure.
    DROP PROCEDURE IF EXISTS  tabinfo;

    CREATE PROCEDURE tabinfo(ptableschema  VARCHAR(30))
    SELECT  t.table_name, engine, table_rows,
                    i.column_name, i.index_name, i.cardinality
    FROM     information_schema.tables t, information_schema.statistics i
    WHERE  t.table_name = i.table_name
          AND  t.table_schema = i.table_schema
          AND  t.table_schema = ptableschema
    ORDER BY t.table_rows DESC;


    -- Execute the tabinfo stored routine using the CALL command.
    mysql> CALL tabinfo('world');

    Monday, September 28, 2009

    Oracle Versus MySQL Classes

    I'm always being asked what is the difference between Oracle classes and MySQL classes. What are the similarities and what are some of the differences? So I thought I'd jot down a few notes.

    Course similarities:
    Oracle Classes
    MySQL Classes
    Oracle Database 11g: Introduction to SQL
    MySQL for Beginners
    Oracle Database 11g: Introduction for Exp. SQL Users
    MySQL for Developers
    Oracle Database 11g: SQL Fundamentals II
    MySQL Developer Techniques
    Oracle Database 11g: PL/SQL Developer
    MySQL Stored Procedures Techniques
    Oracle Database 11g: Administrator Workshop I
    MySQL for DBAs
    Oracle Database 11g: Performance Tuning
    MySQL Performance Tuning
    Oracle Database 11g: RAC Administration
    MySQL Cluster

    Notes on some differences:
    Oracle RAC (MySQL Cluster), PL/SQL (MySQL Stored Procedures), Streams (MySQL HA) have a lot more depth and complexity than MySQL equivalents.
    MySQL does not have a class for MySQL Enterprise Monitor (Oracle Grid).
    MySQL has PHP class, while Oracle has Java, Fusion Middleware, APEX and Forms developer classes

    Tuesday, September 8, 2009

    MySQL Continues to be a "Tipping Point" in the IT Industry




















    MySQL continues to be a tipping point for the IT industry.  In March of 2008 and January 2009 I talked about MySQL being a very important factor in the IT industry.  Today, MySQL  continues to play an important role in the direction of the IT industry.  Some facts about MySQL in a down economy:
    • While technical conferences are being canceled or running at 50% attendance of previous years, the MySQL conference ran at 100% attendance.
    • MySQL continues to enjoy significant revenue growth.
    • The number of MySQL database servers continue to increase at a constant pace.
    • The passion of Dolphins remains very high.
    So it will be interesting to watch what happens to MySQL in the next year.  Who knows there may be a future appendix to "The MySQL Story".    "Everybody, please fasten your seat belts."

    Friday, September 4, 2009

    Configuring INFORMATION_SCHEMA Plugin Tables for InnoDB Plugin

    There are seven new INFORMATION_SCHEMA tables (plugins) available with the InnoDB plugin.  They need to be loaded to be used.

    New InnoDB Plugins contain information on:
    • Compressed InnoDB tables
    • Compressed InnoDB buffer pool
    • Current InnoDB transactions
    • Transaction Locks
    • Blocking transactions
    These INFORMATION_SCHEMA plugins are available by setting the plugin-load parmeter:

    plugin-load=innodb=ha_innodb_plugin.dll;innodb_trx=ha_innodb_plugin.dll;innodb_locks=ha_innodb_plugin.dll;innodb_cmp=ha_innodb_plugin.dll;innodb_cmp_reset=ha_innodb_plugin.dll;innodb_cmpmem=ha_innodb_plugin.dll;innodb_cmpmem_reset=ha_innodb_plugin.dll;

    mysql> SELECT table_name, engine, table_type FROM information_schema.tables
                 WHERE table_name LIKE 'innodb%'
     
    table_nameenginetable_type
    INNODB_CMP_RESETMEMORYSYSTEM VIEW
    INNODB_TRXMEMORYSYSTEM VIEW
    INNODB_CMPMEM_RESETMEMORYSYSTEM VIEW
    INNODB_CMPMEMORYSYSTEM VIEW
    INNODB_CMPMEMMEMORYSYSTEM VIEW
    INNODB_LOCKSMEMORYSYSTEM VIEW


    Before loading plugin tables: 

    mysql>  SHOW PLUGINS;
    NameStatusTypeLibraryLicense
    binlogACTIVESTORAGE ENGINEGPL
    ARCHIVEACTIVESTORAGE ENGINEGPL
    BLACKHOLEACTIVESTORAGE ENGINEGPL
    CSVACTIVESTORAGE ENGINEGPL
    FEDERATEDDISABLEDSTORAGE ENGINEGPL
    MEMORYACTIVESTORAGE ENGINEGPL
    MyISAMACTIVESTORAGE ENGINEGPL
    MRG_MYISAMACTIVESTORAGE ENGINEGPL
    partitionACTIVESTORAGE ENGINEGPL
    InnoDBACTIVESTORAGE ENGINEha_innodb_plugin.dllGPL

    After loading plugin tables: 

    mysql>  SHOW PLUGINS;

    NameStatusTypeLibraryLicense
    binlogACTIVESTORAGE ENGINEGPL
    ARCHIVEACTIVESTORAGE ENGINEGPL
    BLACKHOLEACTIVESTORAGE ENGINEGPL
    CSVACTIVESTORAGE ENGINEGPL
    FEDERATEDDISABLEDSTORAGE ENGINEGPL
    MEMORYACTIVESTORAGE ENGINEGPL
    MyISAMACTIVESTORAGE ENGINEGPL
    MRG_MYISAMACTIVESTORAGE ENGINEGPL
    partitionACTIVESTORAGE ENGINEGPL
    InnoDBACTIVESTORAGE ENGINEha_innodb_plugin.dllGPL
    INNODB_TRXACTIVEINFORMATION SCHEMAha_innodb_plugin.dllGPL
    INNODB_LOCKSACTIVEINFORMATION SCHEMAha_innodb_plugin.dllGPL
    INNODB_CMPACTIVEINFORMATION SCHEMAha_innodb_plugin.dllGPL
    INNODB_CMP_RESETACTIVEINFORMATION SCHEMAha_innodb_plugin.dllGPL
    INNODB_CMPMEMACTIVEINFORMATION SCHEMAha_innodb_plugin.dllGPL
    INNODB_CMPMEM_RESETACTIVEINFORMATION SCHEMAha_innodb_plugin.dllGPL

    InnoDB parameters example:
    [mysqld]
    basedir="C:/mysql/5.1.38/"
    datadir="C:/mysql/Data/"

    #*** INNODB Specific options ***
    ignore-builtin-innodb
    plugin-load=innodb=ha_innodb_plugin.dll;innodb_trx=ha_innodb_plugin.dll;innodb_locks=ha_innodb_plugin.dll;innodb_cmp=ha_innodb_plugin.dll;innodb_cmp_reset=ha_innodb_plugin.dll;innodb_cmpmem=ha_innodb_plugin.dll;innodb_cmpmem_reset=ha_innodb_plugin.dll

    plugin_dir="C:/mysql/5.1.38/lib/plugin"

    default-storage-engine=INNODB
    innodb_data_home_dir="C:/mysql/innodb"

    innodb_data_file_path=ibdata1:1G;ibdata2:1G:autoextend
    innodb_autoextend_increment=100
    innodb_log_group_home_dir="C:/mysql/innologs"

    innodb_buffer_pool_size=120M
    innodb_log_file_size=100M

    InnoDB Plugin Parameters

     Here is the set of new parameters available with the InnoDB Plugin 1.0.4


    NameScopeDynamicDefault
    innodb_adaptive_flushingGLOBALYESTRUE
    innodb_change_bufferingGLOBALYESinserts
    innodb_file_formatGLOBALYESAntelope
    innodb_file_format_checkGLOBALYESON
    innodb_io_capacityGLOBALYES200
    innodb_read_ahead_thresholdGLOBALYES56
    innodb_read_io_threadsGLOBALNO4
    innodb_spin_wait_delayGLOBALYES6
    innodb_stats_sample_pagesGLOBALYES8
    innodb_strict_modeGLOBAL|SESSIONYESFALSE
    innodb_use_sys_mallocGLOBALNOTRUE
    innodb_write_io_threadsGLOBALNO4

    Parameters with New Defaults for InnoDB Plugin 1.0.4
    NameOld DefaultNew Default
    innodb_additional_mem_pool_size1MB8MB
    innodb_buffer_pool_size8MB128MB
    innodb_log_buffer_size1MB8MB
    innodb_max_dirty_pages_pct9075
    innodb_sync_spin_loops2030
    innodb_thread_concurrency8

    mysql> SELECT version();
    +------------------+
    | version()        |
    +------------------+
    | 5.1.38-community |
    +------------------+

    mysql> SHOW VARIABLES LIKE 'innodb_version';
    +----------------+-------+
    | Variable_name  | Value  |
    +----------------+-------+
    | innodb_version  | 1.0.4   |
    +----------------+-------+


    InnoDB Parameters After Setting Plugin

    Query show variables like '%innodb%';
    Output From Command:show variables like '%innodb%';
    Variable_nameValue
    have_innodbYES
    ignore_builtin_innodbON
    innodb_adaptive_flushingON
    innodb_adaptive_hash_indexON
    innodb_additional_mem_pool_size8388608
    innodb_autoextend_increment8
    innodb_autoinc_lock_mode1
    innodb_buffer_pool_size134217728
    innodb_change_bufferinginserts
    innodb_checksumsON
    innodb_commit_concurrency0
    innodb_concurrency_tickets500
    innodb_data_file_pathibdata1:10M:autoextend
    innodb_data_home_dir(null)
    innodb_doublewriteON
    innodb_fast_shutdown1
    innodb_file_formatAntelope
    innodb_file_format_checkAntelope
    innodb_file_io_threads4
    innodb_file_per_tableOFF
    innodb_flush_log_at_trx_commit1
    innodb_flush_method(null)
    innodb_force_recovery0
    innodb_io_capacity200
    innodb_lock_wait_timeout50
    innodb_locks_unsafe_for_binlogOFF
    innodb_log_buffer_size8388608
    innodb_log_file_size5242880
    innodb_log_files_in_group2
    innodb_log_group_home_dir.\
    innodb_max_dirty_pages_pct75
    innodb_max_purge_lag0
    innodb_mirrored_log_groups1
    innodb_open_files300
    innodb_read_ahead_threshold56
    innodb_read_io_threads4
    innodb_replication_delay0
    innodb_rollback_on_timeoutOFF
    innodb_spin_wait_delay6
    innodb_stats_on_metadataON
    innodb_stats_sample_pages8
    innodb_strict_modeOFF
    innodb_support_xaON
    innodb_sync_spin_loops30
    innodb_table_locksON
    innodb_thread_concurrency0
    innodb_thread_sleep_delay10000
    innodb_use_sys_mallocON
    innodb_version1.0.4
    innodb_write_io_threads4
    50 rows in set (0.00 sec)


    InnoDB Parameters Before Setting Plugin

     mysql> SHOW VARIABLES LIKE 'ignore_builtin_innodb';
    +-----------------------+-------+
    | Variable_name             | Value |
    +-----------------------+-------+
    | ignore_builtin_innodb    | OFF    |
    +-----------------------+-------+

    Output From Command:  show variables like '%innodb%';
    Variable_nameValue
    have_innodbYES
    ignore_builtin_innodbOFF
    innodb_adaptive_hash_indexON
    innodb_additional_mem_pool_size1048576
    innodb_autoextend_increment8
    innodb_autoinc_lock_mode1
    innodb_buffer_pool_size8388608
    innodb_checksumsON
    innodb_commit_concurrency0
    innodb_concurrency_tickets500
    innodb_data_file_pathibdata1:10M:autoextend
    innodb_data_home_dir(null)
    innodb_doublewriteON
    innodb_fast_shutdown1
    innodb_file_io_threads4
    innodb_file_per_tableOFF
    innodb_flush_log_at_trx_commit1
    innodb_flush_method(null)
    innodb_force_recovery0
    innodb_lock_wait_timeout50
    innodb_locks_unsafe_for_binlogOFF
    innodb_log_buffer_size1048576
    innodb_log_file_size5242880
    innodb_log_files_in_group2
    innodb_log_group_home_dir.\
    innodb_max_dirty_pages_pct90
    innodb_max_purge_lag0
    innodb_mirrored_log_groups1
    innodb_open_files300
    innodb_rollback_on_timeoutOFF
    innodb_stats_on_metadataON
    innodb_support_xaON
    innodb_sync_spin_loops20
    innodb_table_locksON
    innodb_thread_concurrency8
    innodb_thread_sleep_delay10000
    innodb_use_legacy_cardinality_algorithmON
    37 rows in set (0.00 sec)

    Configuring the InnoDB Plugin (1.0.4) in MySQL 5.1.38

    The InnoDB Plugin (1.0.4) is  pretty straight forward configuration. These instructions are for MySQL 5.1.38.  There is a new release of InnoDB Plugin with the 5.1.41 release. With MySQL you can use the default version of InnoDB or the new Plugin but not both.  If using a non-default configuration make sure and set the plugin_dir variable to point to the ha_innodb_plugin library for your system. 

    To use the new plugin set the following parameters in your my.ini or my.cnf file.

    Make sure you set the paths right for your setup and the right MySQL release like 5.1.40, etc.  

    Setting the InnoDB Plugin on Unix/Linux:

    [mysqld]
    ignore-builtin-innodb
    plugin_dir=/opt/mysql/5.1.38/lib/mysql/plugin
    plugin-load=ha_innodb_plugin.so


    Setting the InnoDB Plugin on Windows:
    [mysqld]
    ignore-builtin-innodb
    plugin-load=innodb=ha_innodb_plugin.dll
    plugin_dir="C:/mysql/5.1.38/lib/plugin"

    mysql> SHOW VARIABLES WHERE variable_name like '%plugin%' OR  variable_name like '%builtin%';
    Variable_name
    Value
    ignore_builtin_innodb
    ON
    plugin_dir
    C:/mysql/5.1.38/lib/plugin

    My initial settings using the InnoDB Plugin on Windows
    [mysqld]
    basedir="C:/mysql/5.1.38/"
    datadir="C:/mysql/Data/"

    #*** INNODB Specific options ***
    ignore-builtin-innodb
    plugin_dir="C:/opt/mysql/5.1.38/lib/plugin"
    plugin-load=innodb=ha_innodb_plugin.dll


    default-storage-engine=INNODB
    innodb_data_home_dir="C:/mysql/innodb"
    innodb_data_file_path=ibdata1:1G;ibdata2:1G:autoextend
    innodb_autoextend_increment=100
    innodb_log_group_home_dir="C:/mysql/innologs"

    innodb_buffer_pool_size=120M
    innodb_log_file_size=100M

    Thursday, September 3, 2009

    MySQL 5.1.38 Releases with InnoDB Plugin

    The MySQL 5.1.38 release is available today with the InnoDB Plugin (1.0.4) included in the software distribution.  The InnoDB Plugin offers some key features:
    • Improved performance and scalability.
    • Important management features that will be very helpful to MySQL DBAs.    
    I recommend you look into the new features available with the InnoDB Plugin. The InnoDB Plugin (1.0.4) is at end of beta cycle. This storage engine can replace the default InnoDB storage engine by making a few configuration changes.  Blog on Thursday, April 9, 2009 InnoDB Plugin Has Some Very Cool Features highlights the Oracle InnoDB Plugin.

    For documentation on installing MySQL 5.1.38 or upgrading from previous MySQL releases, look here:
    To look at the changes in the 5.1.38 release compared to the previous release look here.  

    Wednesday, August 26, 2009

    Oracle Fusion Middleware 11g Launch - Denver

    This was accidently posted to the MySQL blog site.  The full article on Oracle Fusion middleware can be found at http://fusioninsidersedition.blogspot.com.

    Monday, July 13, 2009

    Moving from MySQL to an Oracle Database Server

    I was asked recently in one of my blogs what are some of the pure technical advantages of moving from MySQL to Oracle. I kind of laughed when I read the question because nothing is likely to stir up more perspectives and emotions than asking about moving from one database server vendor to another. So here goes ten technical considerations of moving to an Oracle database server from a MySQL server. I'm keeping the list to pure database server technology. There are also a lot of reasons to move to MySQL as well from other database server vendors (my whole blog is on this).

    Technical Advantages moving from a MySQL Server to an Oracle database server
    1. Scalability: Much higher vertical scalability and higher OLTP transaction capability. Ability to set up shared server architecture for more user connection scalability.
    2. Metadata: Lots of very detailed metadata information as well as wait events for tuning.
    3. Stored Routines: Compiled stored procedures with much higher scalability. Java and .NT stored procedure capability.
    4. SQL functionality: Lots of SQL functions and analytical SQL functions. Lots of XML functionality built into database server.
    5. Backups: Hot online backups with Oracle's Recovery Manager
    6. Automatic Management: Lots of automatic management with Automatic Database Diagnostic Management (ADDM), Advisors, Automatic Workload Repository (AWR) , Automatic Segment Management, Shared Memory Management, etc.
    7. Data Warehousing: Bitmap indexes, materialized views, analytical functions, star joins, sort-merge joins, hash joins, etc.
    8. Grid Control: Oracle Enterprise Manager is a very robust enterprise tool for managing and monitoring multiple tiers of an Oracle infrastructure.
    9. Inexpensive disk strategy: Striping and mirroring capability with Oracle's Automatic Storage Management (ASM).
    10. Flashback technology: Lots of recovery capability with Flashback technology such as Flashback Database, Flashback Table, Flashback Versions Query, etc.

    Anyway, a few things to talk about over coffee and cookies. :)

    Wednesday, July 1, 2009

    Differences between Oracle and MySQL

    Some key differences for DBAs between Oracle and MySQL database servers include:
    • Different tools used to manage and monitor database servers.
    • Oracle architecture is process based, MySQL architecture is thread based.
    • Different tools used for backup and recovery.
    • Database specific SQL syntax.
    • Database specific SQL functions.
    • Different syntax for stored routines. MySQL has no packages.
    • MySQL routines are not compiled and run in each session thread and not in global memory.
    • MySQL only supports row-level triggers.
    • Different startup and shutdown processes.
    • Oracle RAC is a shared disk solution while MySQL Cluster is a shared nothing solution.
    • The default configuration for MySQL is very lenient in terms of data integrity. A MySQL DBA must tighten down data integrity for it to work like traditional databases.
    • With Oracle, the CREATE DATABASE command is used to create the physical storage for the database server.
    • With MySQL, the mysql_install_db script is used to create the physical storage for the database server.
    • The term "database" in Oracle means all the physical files associated with an instance.
    • The term "database" in MySQL means a schema. The term database and schema can be used interchangeably in MySQL.
    • In Oracle a database user owns all the schema objects.
    • In MySQL the database schema owns all the schema objects.
    • Oracle supports role based security. With MySQL, scripts and stored routines are used to programatically organize security permissions.
    • Oracle has a lot more feature functionality that makes it very popular.
    • MySQL has a lot less functionality than Oracle that makes it very popular.
    • Oracle has tons of options for creating a table. Different characteristics and behavior are defined with these options.
    • The key with MySQL tables are defining a storage engine with a table. The storage engine defines characteristics such as row level locking versus table level locking, referential integrity, support for different types of indexes and features. Different optimizations, storage, tuning and backup and recovery are required for each storage engine. Storage engines are a KEY feature in MySQL.
    • MySQL supports different ISOLATION levels of READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ AND SERIALIZABLE.
    Oracle DBAs are not just managing Oracle databases any longer. They are supporting, SQL Server, MySQL, Business applications, application servers in a lot of Oracle environments. The more software you can support in an organization the more marketable you are. Its important that Oracle DBAs be able to support the corporate environments that are running database software from multiple vendors and the software surrounding databases.

    There are reasons that MySQL customers like the light weight, easy to use MySQL database server. If an Oracle DBA compares MySQL to Oracle feature by feature they are going to be very disappointed. An Oracle DBA needs to look at the feature/functionality that makes MySQL so popular. The feature/functionality is not tons of features, its that it is light weight, fast and easy to manage.

    The closest analogy I can make to an experienced Oracle DBAs, is that a MySQL database server is similar in management to what an Oracle version 7 database was like. MySQL uses cache hit ratios, has minimal wait events and DBAs still need to write scripts to surround the MySQL database.

    Starting up and Shutting Down a MySQL Server

    There are different ways for starting up and shutting down a MySQL server. A MySQL server when it starts up it starts up all the way. When a MySQL server shuts down it shuts down all the way. MySQL cannot startup and and shutdown at different levels the way an Oracle database server can.

    MySQL Optimal Configuraton Architecture

    Oracle DBAs understand the importance of defining guidelines and standards and using them in the configuration and management of database servers. Years ago the Optimal Configuration Architecture (OFA) developed a base set of guidelines and naming conventions for Oracle DBAs.

    I developed the MySQL Optimal Configuration Architecture (MOCA) modeled after OFA to give new MySQL DBAs a set of guidelines and standards to consider when configurating MySQL database servers.

    Managing MySQL Storage

    Storage needs to be managed for any MySQL instance. A MySQL database server does not have the same flexibility as an Oracle database server in terms of how to lay out the data storage. It is important to learn the data storage defaults and options.


    Tuesday, June 30, 2009

    Managing the MySQL Instance

    An Oracle DBA needs to learn how to manage a MySQL Instance. The MySQL instance has different memory buffers and caches like any database server. Part of MySQL's uniqueness is that it has memory areas to be configured that are associated with different types of storage engines.

    Learning the MySQL Architecture

    MySQL is an database server and anyone managing the MySQL database server has to learn the architecture, and feature functionality like any other database server. The biggest mistake to make with a new MySQL environment is thinking it is a toy and trivial to work with. A MySQL server needs to be properly configured, tuned and managed like any other database server.

    The key to learning any database server is to learn its feature/functionality and the architecture.

    Oracle vs. MySQL

    As MySQL continues to explode in the marketplace, there are more Oracle and SQL Server DBAs learning MySQL. For Oracle DBAs, its important to understand that MySQL is a different type of database server.
    • Oracle is the aircraft carrier of database servers. Oracle has by far more features than any other database server. Oracle supports a number of database server solutions such as Real Application Clusters (RAC), Data Guard (standby database) and Oracle Streams (replication).
    • MySQL is the speed boat of database servers. MySQL is a very light weight database server that excels in web applications. MySQL is designed to be fast, easy to use and simple to install.
    I'm always asked about porting Oracle applications to MySQL or MySQL applications to Oracle. Well if someone buys an aircraft carrier they probably bought it for specific reasons and the same for a speed boat. Its very unlikely that someone is going to switch from one to the other and be happy. However, each database server has areas where it excels.

    MySQL Workbench 5.1.16 is GA!

    MySQL Workbench Version 5.1.16 the General Availability build can be downloaded at http://dev.mysql.com/downloads/workbench/5.1.html.


    Congratulations to the Workbench team for their great effort in this release.

    Thursday, June 11, 2009

    Converting an Oracle Schema to MySQL

    Both Oracle and MySQL provide a number of sample schemas so users can build different schema environments and load them with data. So I thought I'd get one of the Oracle sample schemas and go through the exercise of converting it to a MySQL schema. I could have gone in either direction, since this is more of a MySQL blog I made MySQL the destination. Before I start let me introduce some of the Oracle and MySQL sample schemas.

    Oracle Sample Schemas:
    • Human Resources: (HR) is a simple schema containing tables with basic primary and foreign key relationships such as: employees, departments, jobs, locations, regions, countrys, jobs, etc. This can be extended to support Oracle Internet Directory demos.
    • Order Entry (OE) is a more complex set of tables demonstrating the different datatypes supported by Oracle. Tables dealing with products, sales, customers, etc. are used in this schema.
    • Online Catalog (OC) is a supporting schema that demonstrates object-relational database objects built inside the OE schema.
    • Product Media (PM) is a schema that supports multimedia datatypes. Audio, video, images, large text data are all used in this schema.
    • Queued Shipping (QS) to demonstrate Oracle Advanced Queuing capabilities. Advanced Queuing and XML are used in this schema.
    • Sales History (SH) is a schema supporting a large number of tables. Features like partitioning and Oracle analytics can be used with this schema.

    MySQL Sample Schemas:
    • World is a basic schema using three tables City, Country and CountryLanguages that use MyISAM tables.
    • Sakila is a schema that adds additional complexity using an online DVD store to demonstrate more of the MySQL 5.1 features.
    • Employees is a schema with a much larger data set containing employees, deparments, salaries, titles, etc that are very intuitive to work with. There are approximately 4 million records to work with. Different storage engines and partitioning are often benchmarked using this schema.
    Summary of changes made to convert Oracle Schema to MySQL Schema

    Here is a summary of changes made to convert the Oracle schema script to a MySQL schema script. The goal here is to provide a level of understanding of converting a schema.
    • Comment out SQL*Plus specific commands.
    • Change REM to --
    • Change VARCHAR2 to VARCHAR
    • Change NUMBER to INT
    • Change NUMBER(x,x) to DECIMAL(x,x)
    • Change CONSTRAINT keyword Syntax
    • For InnoDB tables, define PRIMARY KEY as part of the CREATE TABLE command and not a separate CREATE INDEX command.
    • Make sure tables are created as InnoDB. set storage_engine=innodb;
    • Modify constraint syntax for FOREIGN KEY definitions.
    • Fully quality PRIMARY KEY column in FOREIGN KEY constraint.
    • Remove READ ONLY clause with CREATE VIEW.

    Converting the Oracle HR sample schema to MySQL

    I decided the Oracle HR schema would be a good sample schema to convert to a MySQL schema to demonstrate things to consider in creating schema scripts. I started with the cre_hr.sql script and converted it to a cre_hr_mysql.sql script. The Oracle cre_hr.sql script I started with can be found at:
    • http://www.oracle.com/technology/obe/sqldev_obe/osdm/files/hr_cre.sql

    MySQL equivalent of the Oracle HR schema script

    Here is the corresponding MySQL create script. The only thing I did not address were the sequential incremental values used with Oracle sequences. I included the Oracle CREATE SEQUENCE commands in so it would show the adjustments I made to use autoincrement but also show that the incremental values would need to be addressed. A little more work needs to be done here to verify the data loads would create the same values in an Oracle environment. As I mentioned my main goal was to give someone a feel for the code differences in creating a schema between Oracle and MySQL.

    -- hr_cre_mysql.sql


    /*
    Notes of changes:
    Comment out SQL*Plus specific commands.
    Change REM to --
    Change VARCHAR to VARCHAR
    Change INT to INT
    Change INT(x,x) to DECIMAL(x,x)
    Change CONSTRAINT keyword Syntax
    For InnoDB tables, define PRIMARY KEY as part of the CREATE TABLE command and not a separate CREATE INDEX command.
    Make sure tables are created as InnoDB.
    set storage_engine=innodb;
    Modify constraint syntax for FOREIGN KEY definitions.
    Fully quality PRIMARY KEY column in FOREIGN KEY constraint.
    Remove READ ONLY clause with CREATE VIEW.
    */

    DROP DATABASE IF EXISTS hr;
    CREATE DATABASE hr;
    USE hr;

    CREATE TABLE regions
    ( region_id INT NOT NULL
    , region_name varchar(25),
    primary key (region_id)
    );


    CREATE TABLE countries
    ( country_id CHAR(2) NOT NULL
    , country_name varchar(40)
    , region_id INT
    , PRIMARY KEY (country_id)
    ) ;


    ALTER TABLE countries
    ADD (FOREIGN KEY (region_id)
    REFERENCES regions(region_id)
    ) ;

    CREATE TABLE locations
    ( location_id INT(4)
    , street_address varchar(40)
    , postal_code varchar(12)
    , city varchar(30) NOT NULL
    , state_province varchar(25)
    , country_id CHAR(2)
    , PRIMARY KEY (location_id)
    ) auto_increment=3300;

    /*
    CREATE SEQUENCE locations_seq\
    START WITH 3300\
    INCREMENT BY 100\
    MAXVALUE 9900\
    NOCACHE\
    NOCYCLE;\
    */

    ALTER TABLE locations
    ADD ( FOREIGN KEY (country_id)
    REFERENCES countries(country_id)
    ) ;

    CREATE TABLE departments
    ( department_id INT(4)
    , department_name varchar(30) NOT NULL
    , manager_id INT(6)
    , location_id INT(4)
    , PRIMARY KEY (department_id)
    ) auto_increment=280;

    ALTER TABLE departments
    ADD ( FOREIGN KEY (location_id)
    REFERENCES locations (location_id)
    ) ;

    /*
    CREATE SEQUENCE departments_seq\
    START WITH 280\
    INCREMENT BY 10\
    MAXVALUE 9990\
    NOCACHE\
    NOCYCLE;\
    */

    CREATE TABLE jobs
    ( job_id VARCHAR(10)
    , job_title VARCHAR(35) NOT NULL
    , min_salary INT(6)
    , max_salary INT(6)
    , PRIMARY KEY (job_id)
    ) ;


    CREATE TABLE employees
    ( employee_id INT(6)
    , first_name varchar(20)
    , last_name varchar(25) NOT NULL
    , email varchar(25) NOT NULL
    , phone_INT varchar(20)
    , hire_date DATE NOT NULL
    , job_id varchar(10) NOT NULL
    , salary DECIMAL(8,2)
    , commission_pct DECIMAL(2,2)
    , manager_id INT(6)
    , department_id INT(4)
    , UNIQUE KEY (email)
    , PRIMARY KEY (employee_id)
    ) auto_increment=207;

    DELIMITER //
    CREATE TRIGGER emp_sal_min BEFORE INSERT ON employees
    FOR EACH ROW
    BEGIN
    IF (salary <= 0 ) THEN call unknown(); END IF; END// DELIMITER ; ALTER TABLE employees ADD ( FOREIGN KEY (department_id) REFERENCES departments(department_id)); ALTER TABLE employees ADD ( FOREIGN KEY (job_id) REFERENCES jobs (job_id)); ALTER TABLE employees ADD ( FOREIGN KEY (manager_id) REFERENCES employees(employee_id)) ; ALTER TABLE departments ADD ( FOREIGN KEY (manager_id) REFERENCES employees (employee_id)) ; /* CREATE SEQUENCE employees_seq\ START WITH 207\ INCREMENT BY 1\ NOCACHE\ NOCYCLE;\ */ CREATE TABLE job_history ( employee_id INT(6) NOT NULL , start_date DATE NOT NULL , end_date DATE NOT NULL , job_id VARCHAR(10) NOT NULL , department_id INT(4) , PRIMARY KEY (employee_id, start_date) ) ; DELIMITER // CREATE TRIGGER jobhist_dates BEFORE INSERT ON job_history FOR EACH ROW BEGIN IF (end_date > start_date ) THEN call unknown();
    END IF;
    END//

    DELIMITER ;

    ALTER TABLE job_history
    ADD (FOREIGN KEY (job_id)
    REFERENCES jobs(job_id));


    ALTER TABLE job_history
    ADD ( FOREIGN KEY (employee_id)
    REFERENCES employees(employee_id));

    ALTER TABLE job_history
    ADD (FOREIGN KEY (department_id)
    REFERENCES departments(department_id)) ;


    CREATE OR REPLACE VIEW emp_details_view
    (employee_id, job_id, manager_id,
    department_id, location_id, country_id,
    first_name, last_name, salary,
    commission_pct, department_name, job_title,
    city, state_province, country_name, region_name)
    AS SELECT
    e.employee_id, e.job_id, e.manager_id,
    e.department_id, d.location_id, l.country_id,
    e.first_name, e.last_name, e.salary,
    e.commission_pct, d.department_name, j.job_title,
    l.city, l.state_province, c.country_name, r.region_name
    FROM
    employees e, departments d, jobs j,locations l,
    countries c, regions r
    WHERE e.department_id = d.department_id
    AND d.location_id = l.location_id
    AND l.country_id = c.country_id
    AND c.region_id = r.region_id
    AND j.job_id = e.job_id ;

    Tuesday, June 9, 2009

    MySQL Workbench - Export Features

    MySQL Workbench has some nice export features. They include:
    • Forward engineer SQL Create Script
    • Forward Engineer SQL ALTER Script
    • Synchronize With SQL Create Script
    • Export as PNG
    • Export as SVG
    • Export as Single Page PDF
    • Export as Single Page PostScript File
    Export options (just choose File Menu then Export option):












    MySQL Workbench 5.2 - Some nice features

    MySQL Workbench 5.2 Alpha

    My understanding is the MySQL Workbench 5.2 has the core 5.1 modeling features as well as the new Query Browser. The Query Browser has been easy to use but the feature functionality is still in the alpha phase. Adding the Query Browser in the 5.2 release adds a nice dimension of being able to look at the data model, physical table and data very easily. So far I have found the tool very intuitive and have not had to spend any time figuring things out. So far I have not done any benchmarking on the product.

    New Query Browser




















    Reverse Engineering Feature


    I used the reverse engineering feature with the Sakila sample schema and it was point and click and the data model was built in just a second. Notice the ERD diagram in the top left, hierarchy of schemas and objects on right side and detailed table definition at bottom left.