• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
My sql crashcourse_intro_kdl
 

My sql crashcourse_intro_kdl

on

  • 728 views

MySQL Crashcourse @ RMOUG labs 2011

MySQL Crashcourse @ RMOUG labs 2011

Statistics

Views

Total Views
728
Views on SlideShare
682
Embed Views
46

Actions

Likes
0
Downloads
8
Comments
0

5 Embeds 46

http://sqlhjalp.blogspot.com 37
http://sqlhjalp.blogspot.in 6
http://sqlhjalp.blogspot.it 1
http://sqlhjalp.blogspot.dk 1
http://sqlhjalp.blogspot.hk 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    My sql crashcourse_intro_kdl My sql crashcourse_intro_kdl Presentation Transcript

    • <Insert Picture Here>MySQL: Crash Course IntroductionKeith Larsonkeith.larson@oracle.comMySQL Community Manager
    • The following is intended to outline our general productdirection. It is intended for information purposes only, andmay not be incorporated into any contract. It is not acommitment to deliver any material, code, orfunctionality, and should not be relied upon in makingpurchasing decisions.The development, release, and timing of any features orfunctionality described for Oracle’s products remains atthe sole discretion of Oracle.Safe Harbor Statement
    • Who am I and who are you?Keith Larsonkeith.larson@oracle.comMySQL Community Managersqlhjalp.blogspot.comStarted with MySQL during the dot.com days.Primary real world work was with a MySQL InnoDB replicatedchain environment that easily held over 4 billion rows of userdata.Numerous other sites developed on LAMP stack over the last13 years.Who are you?–  DBAs?–  Developers?–  Already have replicated databases?–  Cluster Users or Cluster curious?
    • • Oracles Investment into MySQL• Provide high-level overview• Familiarize with the key concepts• Emphasize MySQL specificity• Community Edition, version 5.5 GAAgenda
    • The official way to pronounce “MySQL” is“My Ess Que Ell”but we do not mind if you pronounce it as“my sequel”Pronouciation
    • MySQL Crash CourseStarted in 80sAcquired by SUN Microsystems in 2008 for 1B USDAcquired by Oracle in 2009Dual licensing: GPL v.2 + commercial“M” in “LAMP” stackEasy of use: the 15 minute ruleBackground of MySQL
    • MySQL Makes The Cover!
    • Built togetherTested togetherManaged togetherServiced togetherBased on open standardsLower costLower riskMore reliableHardware and SoftwareEngineered to Work TogetherMySQL Completes The Stack
    • More Product Releases Than Ever BeforeContinuous InnovationQ2 CY2010 Q3 CY2010 Q4 CY2010 Q1 CY2011• MySQL Workbench 5.2GA!• MySQL Database 5.5• MySQL Enterprise Backup 3.5• MySQL Enterprise Monitor 2.3• MySQL Cluster Manager 1.1All GA!A Better MySQLQ2 CY2011• MySQL Enterprise Monitor 2.2• MySQL Cluster 7.1• MySQL Cluster Manager 1.0All GA!• MySQL Database5.6• MySQL Cluster 7.2DMR*and MySQL Labs!(“early and often”)*Development Milestone Release
    • Enterprise 2.0SaaS, CloudWeb OEM / ISV’sTelecommunicationsIndustry Leading CustomersRely on MySQL
    • >70% of Oracle shops run MySQLmysql.com/downloads/MySQL: Still Free, Open to the CommunityAvailable to download and use under the GPL:• MySQL Database (Community Server)• MySQL Cluster• MySQL Workbench Community Edition• MySQL Connectors• MySQL Proxy• Documentation (free to use, not covered under GPL)• Forums
    • “I’m really blown away by MySQL 5.5’s improvements. “- Don MacAskill, SmugMug“My expectations for 5.5 were not high. I am pleasantlysurprised!”- Mark Callaghan, Facebook, MySQL UC Keynote"Oracle really did a great job with MySQL 5.5 -- in recordtime! It has lots of new features and performanceimprovements that our customers need andwant. Were very excited about this release."- Sheeri K. Cabral, Oracle Ace Director andDatabase Operations Manager, PalominoDBMySQL 5.5 Early Adopters Speak! GA
    • MySQL ComponentsMySQLServerMySQL Workbenchmysql (cmd-line client)System ToolsMySQL Enterprise MonitorDirect I/O“Not Only SQL”NoSQLMySQLProxyCnCnCnYour ApplicationCnSQL
    • MySQL ServerStandalone (mysqld)UNIX daemonWindows serviceRegular process on UNIX or WindowsEmbedded (libmysqld)Shared / Dynamic library
    • MySQL Server ComponentsInnoDBDB1InnoDBDB2MyISAMDB3InnoDB MyISAMCoreSQL-query processing, …Plugin 1 Plugin 2 Plugin 3 The CorePluginsStorage EnginesFull-text searchpluginsAudit pluginsAuthenticationplugins…
    • MySQL Server ComponentsSE defines data storage and retrievalEvery regular table belongs to some SEMost known Storage Engines:InnoDB (default since 5.5) – fully transactional SEMyISAM (default prior to 5.5) – NON-transactional SEDefault Storage EngineStorage Engine
    • •  Default Storage Engine for MySQL 5.5 and above•  ACID-compliant transactions, MVCC•  Row-level locking•  Two phase commit•  Efficient indexing•  Fast DDL operations•  Table compression•  Automatic crash recovery•  Referential integrity•  Online backup•  MoreMySQL DatabaseInnoDB - Transactional by Default
    • Storage Engines:Select a specialized storage engine for a particular applicationneed.InnoDB: a high-reliability and high-performance storage enginefor MySQL designed for transaction processing. It follows theACID model. Row-level locking and Oracle-style consistentreads increase multi-user concurrency and performanceMyISAM: -oldest storage engine has many featuresthat have been developed over years.Memory: creates tables with contents that are stored in memory.MySQL Cluster offers the same features as the MEMORYengine with higher performance levels, and providesadditional features
    • Storage Engines:CSV: data file is a plain text fileARCHIVE: is used for storing large amounts of data withoutindexes in a very small footprint.BLACKHOLE:accepts data but throws it away and does notstore it but the binary log is enabled.
    • MySQL Server ComponentsOpen SourceA Storage EngineHorizontal partitioning (distribute rows, notcolumns)Partitioning functions:The modulusRangeInternal hashing functionLinear hashing functionPartitioning
    • MySQL Server ComponentsOpen SourceOne-way, master and slavesAsynchronous or Semi-synchronous replicationReplication formats:Statement-based replication (SBR): propagate SQLstatementsRow-based replication (RBR): propagate row changesMixed-based replication: SBR or RBR depending onthe queryReplication
    • MySQL Replication OverviewNative in MySQLUsed for Scalability andHAAsynchronous asstandardSemi-Synchronoussupport added inMySQL 5.5Each slave addsminimal load on master
    • Writes & Reads Reads Reads• Write to one master• Read from many slaves, easily add more as needed• Perfect for read/write intensive appsApplicationMySQL ReplicationLoad BalancerMySQL DatabaseReplication Enables Scalability
    • Replication Topologies
    • MySQL Server ComponentsOpen SourceDifferent source tree, different versioning (7.x)In-memory, shared-nothing architecture“Synchronous, multi-master replication”Cluster
    • Copyright 2011 Oracle Corporation 26MySQL DatabaseHigh Availability with MySQL Replication
    • MySQL ArchitectureParallel Database with no SPOF: High Read & WritePerformance & 99.999% uptimeMySQL Cluster Data NodesMySQL ClusterApplication NodesClientsMySQLClusterMgmtLDAPRESTNoSQLSQL,JDBC,ODBC,ADO
    • Node Failure Detection & Self-Healing Recovery
    • Cluster – Typical PerformanceAvailability99.999% (<5 min downtime / year)PerformanceResponse Time 2-5 millisecond (with synchronous replicationand access via NDB APIThroughput of 10,000+ replicated transactions/sec on a 2Node Cluster, with 1 CPU Per Node (minimal configuration)Throughput of 100,000 replicated transactions/sec on 4 NodeCluster, with 2 CPU Per Node (low-end configuration)FailoverSub-second failover enables you to deliver servicewithout interruptionGA
    • BackupThe way depends on the applicationPossible solutions:MySQL Enterprise BackupReplicationmysqldump…Overview
    • MySQL Enterprise Backup• Online Backup for InnoDB• Full, Incremental, Partial Backups (scriptable interface)• Compression• Point in Time, Full, Partial Recovery options• Metadata on status, progress, history• Unlimited Database Size• Cross-Platform•  Windows, Linux, Unix• Certified with Oracle Secure BackupMEB BackupFilesMySQLDatabase FilesmysqlbackupEnsures quick, online backup and recovery of your MySQL apps.
    • Is it standard SQL?Yesaim is to support the full ANSI/ISO SQL standard, butwithout makingconcessions to speed andquality of the codeNoDepends on engine
    • MySQL ConceptsMySQL aims to follow The SQL StandardNot PL/SQLPrepared StatementsViewsStored ProgramsSHOW statements and especially SHOWCREATE …Administrative statementsSQL
    • MySQL ConceptsDatabase or SchemaCurrent database (per connection)Database – a set of files in “the data directory”System database (mysql)Virtual databases:INFORMATION_SCHEMAPERFORMANCE_SCHEMADatabase
    • MySQL ConceptsFull Unicode 5.0 for dataEncodings: UTF-8, UTF-16, UTF-32, UCS-2Two encodings for UTF-8:utf8 – 1..3 bytes, BMP onlyutf8mb4 – 1..4 bytes, BMP and supplementalAlias utf8mb3 == utf8Metadata are in utf8(no supplementary characters in identifiers)Unicode
    • MySQL ConceptsKnow your options9 numeric data typesCHAR, VARCHARBLOBsDate/time types…Weak typingSELECT 1 + ‘ 2nd place’ => 3Types
    • MySQL ConceptsError: code, level, SQL-state, messageError messages are localizedError level: errors, warnings, notesThe actual error level depends on configurationSerious errors might be thrown as warnings:SELECT 1 + ‘ 2nd place’Truncated incorrect DOUBLE value: 2nd placeSHOW WARNINGSSQL Conditions
    • MySQL VariablesOverview
    • MySQL VariablesUser Variables:– Weakly typed– SESSION variables– Arbitrary names– Available for any user– No declaration needed– Syntax:– SELECT @a– SET @a = 1User Variables
    • MySQL VariablesSP Variables:– Strongly typed– Only inside SP– Arbitrary names– Must be declared– Syntax:– DECLARE x INT– SELECT x– SET x = 1Stored Program Variables
    • MySQL VariablesSystem Variables:– Configuration options– Fixed names– Fixed types– GLOBAL requires SUPER– Syntax:–  SET / SELECT @@v1–  SET / SELECT @@session.v1–  SET / SELECT @@global.v2–  SHOW VARIABLES LIKE …System Variables
    • MySQL VariablesStatus Variables:– Read-only– Provide stat / information– NotPERFOMANCE_SCHEMA– SHOW GLOBAL STATUS…– SHOW SESSION STATUS…System Variables
    • MySQL ConfigurationHighly configurableCommand line optionsConfiguration files (plain-text, INI-like files withgroups)Several configuration files (/etc, $HOME, …)The last value takes precedence<exe> --help – order of loading filesSQL interface to get or change configurationparametersOverview
    • MySQL ConfigurationVery important variableAffects data consistency!It might be remembered…… or it might be notThus: set it once for all• Recommended value:STRICT_ALL_TABLES |NO_ZERO_DATE |NO_ZERO_IN_DATE |NO_ENGINE_SUBSTITUTION |NO_AUTO_CREATE_USER |IGNORE_SPACE |ERROR_FOR_DIVISION_BY_ZEROSQL MODE
    • MySQL Configuration• SET AUTOCOMMIT = ON | OFF (default: ON)• Auto-commit means COMMIT after each statement• Use START TRANSACTION if you plan to useROLLBACK• START TRANSACTION == BEGIN [WORK]AUTOCOMMIT
    • MySQL ConfigurationDatabase name – directory nameTable name – file name(s)Case-sensitive or case-insensitive ?lower_case_table_names = 0, 1, 2Defines how to name files on diskDefines how to compareSo: use lowercase everywhereIdentifier Case Sensitivity
    • Connecting to The ServerNamed Pipe and Shared Memory are disabled by defaultIPv4 and IPv6 connectivity supportedOverviewProtocolConnectionTypeOperatingSystemsTCP/IPLocal andRemoteAnyUNIX Socket File Local only UNIXNamed Pipe Local only WindowsShared Memory Local only WindowsOverview
    • Connecting to The Server--bind-address can be of use (all: 0.0.0.0)Beware:‘mysql -pfoo’ != ‘mysql -p foo’-pfoo means password is ‘foo’-p foo means “ask password”, and the default database is ‘foo’mysql does SHOW DATABASES and SHOW TABLES onconnectHints
    • Understanding PrivilegesUser or User AccountPrivilege – what is allowed for the userSHOW GRANTS – get privileges for the currentuserSHOW GRANTS FOR …SHOW PRIVILEGES – list of all availableprivilegesBasics
    • Understanding PrivilegesGlobal: GRANT SELECT ON *.* TO …Database: GRANT SELECT ON db1.* TO …Table: GRANT SELECT ON db1.t1 TO …Column: GRANT SELECT(a) ON db1.t1 TO …Server administration privileges – global onlySUPERUSAGEOther privilegesHierarchy
    • Understanding PrivilegesSUPERA “different” privilegeIgnores init_connectBypasses read_only…GRANT ALL ON *.* … grants SUPER!USAGEAllows the user to just connect to the serverMind the default database in client connectionsBeware of …
    • Understanding PrivilegesWITH GRANT OPTIONenables the user to give to / to remove from otherusers those privileges that the user hasGRANT SELECT ON db1.* TO foo@bar WITHGRANT OPTIONGRANT DELETE ON db1.* TO foo@barSHOW GRANTS FOR foo@bar-> GRANT SELECT, DELETE ON db1.*TO foo@bar WITH GRANT OPTIONBeware of …
    • Understanding PrivilegesUser: username@hostnamePrecisely: ‘user-name-mask’@’host-name-mask’Host name – client host name (“from” host name)User name mask:can be empty (anonymous user) – all usersHost name mask:can be empty – all host namescan have ‘%’ (e.g.: %.foo.com)Identifying the User
    • Understanding PrivilegesConnecting as foo from localhost…Should be foo@%, right ?The most specific values are usedBUT: host name matching is done before usernamehost userlocalhost barlocalhost% foo‘’@localhost will be chosen !Anonymous users…
    • Understanding PrivilegesSELECT CURRENT_USER()The authenticated user name and host nameSELECT USER()The user name and host name provided by the clientFor our example:CURRENT_USER(): ‘’@locahostUSER(): foo@localhostUseful Functions
    • Working With TablesRegular tablesTemporary tables (per session)ViewsINFORMATION_SCHEMA tablesPERFORMANCE_SCHEMA tablesOverview
    • Working With TablesMind the storage engine!Temporary tables are in the same namespace !Temporary tables shadow regular ones !5.5: CREATE TEMPORARY TABLES is notenough5.6: CREATE TEMPORARY TABLES is enoughHints
    • The First StepsServer – Community or Enterprise (for 30 days)Cluster –real-time open source transactional database designed forfast, always-on access to data under high throughput conditions.Workbench – visual database design application that can be used toefficiently design, manage and document database schemataProxy – a simple program that sits between your client and MySQLserver(s) that can monitor, analyze or transform their communication.Connectors – ODBC, Java, .Net, MXJ, C/C++, DBI, Ruby, Python,etc.http://dev.mysql.com/downloads/Installation Options
    • How to get MySQLCommunity:Freely downloadable version of the worlds most popular opensource database. It is available under the GPL license and issupported by a huge and active community of open sourcedevelopers.Enterprise:Paid subscription includes support and the following•  MySQL Enterprise Backup•  MySQL Enterprise Security–  External Authentication•  MySQL Enterprise Scalability–  Thread Pool•  MySQL Enterprise High Availability–  Oracle VM Template–  Windows Clustering•  MySQL Enterprise MonitorFree for 30 day evaluation
    • The First StepsChoosing the version5.1 – previous GA version5.5 – the latest GA version5.6 – development releaseChoosing the editionCommunity Edition (Community Server)Enterprise Editions (even MySQL Classic and MySQLStandard)Source or BinaryDownload
    • The First Steps• Where are the configuration filesDefault configuration might be not so goodPerformance, …SQL_MODEAUTOCOMMIT…Post-installation steps: Configuration
    • The First StepsSecure the installationDon’t run under ‘root’Have separate directories (configuration, data, binarylogs, …)Change ‘root’ passwordRemove default accountsPost-installation steps: Security
    • • Reach out to the community–  Irc on freenode–  Forums.mysql.com• Oracle Support• CertificationsMySQL SupportHow can I get help ?
    • • 24 X 7 Problem ResolutionServices• Unlimited Support Incidents• Knowledge Base• Maintenance Releases, Bugfixes, Patches, Updates• MySQL Consultative Support• Staffed by experienced,seasoned MySQL EngineersOracle Premier Support for MySQL
    • •  MySQL Database, Visual Development/Admin, Monitoring,Backup tools, and Oracle Lifetime Support servicesMySQL EnterpriseMonitorPerformanceMonitoring/ AlertsHot fixesService packsMySQL WorkbenchOracle Lifetime SupportMySQL Enterprise BackupMySQL Enterprise EditionQuery AnalyzerDev/Admin, Monitoring/Backup ToolsOracle LifetimeSupport Services
    • •  Oracle High Availability•  Oracle Linux•  Oracle VM + MySQL Template•  Oracle Fusion MiddleWare•  WebLogic Server 10.3.1 +•  Database Adapter for Oracle SOA Suite 11.1.1.1 +•  Oracle BPM 11.1.1.3 +•  Oracle Virtual Directory 11.1.1.1+•  Oracle Data Integrator 11.1.1.3 +•  Oracle Enterprise Performance Management 11.1.2•  Oracle Identity Analytics 11.1.1.3•  Open SSO STS, Open SSO Fedlet 11.1.1.3MySQL Enterprise CertificationsOracle Products
    • •  Oracle Golden Gate•  Bi-directional replication between MySQL and Oracle•  Exadata Data Stores – Enterprise DW, legacy apps,etc.•  Hybrid Applications (MySQL frontend + Oracle datastore)•  Oracle Secure Backup•  MySQL Enterprise Backup 3.6 - supports backupstreaming to OSB via SBT APIMySQL Enterprise CertificationsOracle ProductsEnables you to manage your Oracle and MySQL databaseswith Oracle tools/solutions you are already using.
    • Additional Resourcesmysql.com•  TCO calculator•  White Papers•  Customer use cases and success storiesdev.mysql.com•  Downloads•  Documentation•  Forums•  PlanetMySQLeDelivery.com•  Download and evaluate all MySQL products
    • Additional Resourcesmysql.com•  Download MySQL 5.5, MySQL Cluster 7.1 GA, GPL Products•  MySQL Products, Editions, Licensing Options•  TCO calculator•  Upcoming Events•  Customer use cases and success storiesdev.mysql.com•  Download MySQL 5.6 DMR and Labs “early access” features•  Developer Zone Articles, How to’seDelivery.com•  Download and evaluate all MySQL products
    • Additional ResourcesPlanet.mysql.com•  Blog feeds from the experts and the communityBooks:•  MySQL by Paul DuBois•  MySQL Administrators Bible•  High Performance MySQL: Optimization, Backups, Replication,and Moreforums.mysql.com•  Community interaction
    • Xaprb.comwww.xaprb.com/blog/2009/03/13/50-things-to-know-before-migrating-oracle-to-mysql/50 things to know before migrating Oracle to MySQLIt is a little old but worth the readAdditional Resources
    • <Insert Picture Here>Thanks for attending!keith.larson@oracle.com
    • Extra Slides