MySQL Tutorial


MySQL is (as of July 2013) the world's most widely used open-source relational database management system (RDBMS), enabling the cost-effective delivery of reliable, high-performance and scalable Web-based and embedded database applications. It is widely-used as the database component of LAMP (Linux, Apache, MySQL, Perl/PHP/Python) web application software stack.

MySQL was developed by Michael Widenius and David Axmark in 1994. Presently MySQL is maintained by Oracle (formerly Sun, formerly MySQL AB).

MySQL tutorial of w3resource is a comprehensive tutorial to learn MySQL(5.6). We have hundreds of examples covered, often with PHP code. This helps you to learn how to create PHP-MySQL based web applications.

Production Releases MySQL 5.6 : Latest General Availability (Production) release

Table of Contents :

What is MySQL

  • MySQL is a database management system.
  • MySQL databases are relational.
  • MySQL software is Open Source.
  • The MySQL Database Server is fast, reliable, scalable, and easy to use.
  • MySQL Server works in client/server or embedded systems.
  • Initial release : 23 May 1995
  • Current stable release : 5.6.13 / 30 July 2013
  • Written in : C, C++
  • Operating system : Cross-platform
  • Available in : English
  • The license of MySQL is available under GNU General Public License (version 2) or proprietary EULA.
  • MySQL reduces the Total Cost of Ownership (TCO)

    • Reducing database licensing costs by over 90%
    • Cutting systems downtime by 60%
    • Lowering hardware expenditure by 70%
    • Reducing administration, engineering and support costs by up to 50%

MySQL Editions

There are five types MySQL editions.

  • MySQL Enterprise Edition : This edition includes the most comprehensive set of advanced features, management tools and technical support to achieve the highest levels of MySQL scalability, security, reliability, and uptime.
  • MySQL Standard Edition : This edition enables you to deliver high-performance and scalable Online Transaction Processing (OLTP) applications. It provides the ease of use that has made MySQL famous along with industrial-strength performance and reliability.
  • MySQL Classic Edition : This edition is the ideal embedded database for ISVs, OEMs, and VARs developing read-intensive applications using the MyISAM storage engine.
  • MySQL Cluster CGE : MySQL Cluster is a scalable, real-time, ACID-compliant database, combining 5 x 9s availability and open source technology. With a distributed, multi-master architecture and no single point of failure, MySQL Cluster scales horizontally on commodity hardware accessed via SQL and NoSQL APIs.
  • MySQL Embedded (OEM/ISV) : MySQL Database is a full-featured, zero-administration database that more than 3000 ISVs, OEMs, and VARs rely on to bring their products to market faster and make them more competitive.

Who uses MySQL

  • Some of the most visited websites like Flickr, Facebook, Wikipedia, Google (not for search), YouTube.
  • Content Management Systems like WordPress, phpBB, Drupal, Joomla, TYPO3, MODx.
  • Last but not least, a large number of web developers across the world.

MySQL supported platforms

MySQL runs on

  • Linux (RedHat, SUSE, Mandrake, Debian)
  • Embedded Linux (MontaVista, LynuxWorks BlueCat)
  • Unix (Solaris, HP-UX, AIX)
  • BSD (Mac OS X, FreeBSD)
  • Windows (Windows 2000, Windows NT)
  • RTOS (QNX)

MySQL supported third party tools

Drivers :

  • ODBC
  • JDBC
  • .NET
  • C++

Languages :

  • C
  • C++
  • C#
  • Java
  • Delphi
  • Visual Basic
  • Perl
  • Python
  • PHP

Development Tools :

  • Microsoft Visual Studio
  • Borland Delphi and JBuilder
  • Eclipse
  • NetBeans

Some of the widely used MySQL front ends (tools for managing MySQL)

The MySQL GUI Tools Bundle is a cross-platform open source suite of desktop applications, building and manipulating the data within MySQL databases Development on the GUI Tools bundle has stopped, The GUI Tools bundle has been replaced by MySQL Workbench with the beta releases of MySQL Workbench 5.2. Currently, MySQL Workbench Team are working on Version 6.0. The first public beta, labeled version 6.0.2, was released on June 14, 2013.
There are a lot of third-party free and proprietary graphical administration applications available that integrate with MySQL and users to work with the database. Here are some third-party tools for managing MySQL :

Tools Description
phpMyAdmin Third party, Free, Web-based
HeidiSQL Third party, Free, For Windows
Adminer Third party, Free
DBEdit Third party, Free
dbForge GUI Tools Third party, Free
Navicat Third party, Commercial
Maatkit Third party, Command line, free
MySQL Sandbox Third party, Command line, free
SQLBuddy A free Web-based front end, developed in PHP.
SQLyog Commercial, but a free 'community' edition is available.
Toad for MySQL Third party, free from Quest Software

Key features of MySQL

  • MySQL follows ANSI SQL 99, the standard SQL.
  • Cross Platform.
  • Unicode support
  • ACID compliance
  • Stored procedures
  • Triggers
  • Cursors
  • Views
  • Information schema
  • Strict mode (ensures MySQL does not truncate or otherwise modify data to conform to an underlying data type when an incompatible value is inserted into that type)
  • Independent storage engines
  • Transactions with the InnoDB and NDB Cluster storage engines; savepoints with InnoDB
  • SSL support
  • Query caching
  • Sub-SELECTs (i.e. nested SELECTs)
  • Replication support (i.e. Master-Master Replication & Master-Slave Replication) with one master per slave, many slaves per master
  • Full-text indexing and searching using MyISAM engine
  • Embedded database library
  • Shared-nothing clustering through MySQL Cluster
  • Support for hotbackup
  • Multiple storage engines, allowing one to choose the one that is most effective for each table in the application
  • Commit grouping, gathering multiple transactions from multiple connections together to increase the number of commits per second.

Key relational database features supported by MySQL

  • High-performance
  • Main-memory tables with disk-based tables
  • Single-User and Multi-User
  • Multi-Threaded
  • Multi-Process
  • SQL-92 and SQL-99
  • ACID Transactions
  • Referential Integrity
  • Cascading Updates and Deletes
  • Multi-table Joins
  • Row-level Locking
  • Online Hot Backup
  • Replication
  • Clustering
  • BLOBs (Binary Large Objects)
  • UDFs (User Defined Objects)
  • OLTP (On-Line Transaction Processing)
  • Unicode and Double-Byte character support
  • Drivers for ODBC, JDBC, .NET and C++

Tutorial objectives

1. A short and concise description to help you to understand about the topic / MySQL command.

2. The syntax of the MySQL command with descriptions of all the parameters used.

3. Display of the actual table on which the MySQL command is being applied.

4. How that MySQL command can be executed with PHP.

5. Explanation of the code.

6. The output of the MySQL command when executed from windows command prompt.

7. Display of the output with PHP in a separate browser window.

8. After reading this largest third party online MySQL tutorial by w3resource, you will be able to install, manage and develop PHP-MySQL web applications by your own.

9. You may refer MySQL Documentation along with this tutorial.

We have a comprehensive, SQL TUTORIAL -2003 standard , which will help you to understand how to prepare queries to fetch data against various conditions.

Database Management System

If you are not habituated with database management system your can learn from the following :

Database Management System

You may download the structure and data of the MySQL tables we have used throughout our tutorials here.

Next: MySQL Installation

Follow us on Facebook and Twitter for latest update.