Mysql

This basic MySQL tutorial explains some of the basic SQL statements. If this is the first time you have used a relational database management system, this tutorial gives you everything you need to know to work with MySQL such as querying data, updating data, managing databases, and creating tables.

If you are already familiar with other relational database management systems such as PostgreSQL, Oracle, and Microsoft SQL Server, you can use this tutorial to refresh your knowledge and understand how the SQL dialect of MySQL is different from other systems.

Cloud SQL is a fully managed service that makes it easy to set up, manage, and administer relational databases: PostgreSQL, MySQL, and SQL Server. MySQL Cluster is a real-time open source transactional database designed for fast, always-on access to data under high throughput conditions. MySQL Cluster Plus, everything in MySQL Enterprise Edition.

Section 1. Getting started with MySQL

This section helps you get started with MySQL. We will start installing MySQL, downloading a sample database, and loading data into the MySQL server for practicing.

  • Installing MySQL database server – show you step by step how to install MySQL database server on your computer.
  • Downloading MySQL sample database – introduce you to a MySQL sample database named classicmodels. We also provide you links for downloading the sample database and its diagrams.
  • Loading the sample database into your own MySQL database server – walk you through steps of how to load the classicmodels sample database into your MySQL database server for practicing.

Mysqldump

Section 2. Querying data

This section helps you learn how to query data from the MySQL database server. We will start with a simple SELECT statement that allows you to query data from a single table.

  • SELECT – show you how to use simple SELECT statement to query the data from a single table.

Section 3. Sorting data

  • ORDER BY – show you how to sort the result set using ORDER BY clause. The custom sort order with the FIELD function will be also covered.

Section 4. Filtering data

  • WHERE – learn how to use the WHERE clause to filter rows based on specified conditions.
  • SELECT DISTINCT – show you how to use the DISTINCT operator in the SELECT statement to eliminate duplicate rows in a result set.
  • AND – introduce you to the AND operator to combine Boolean expressions to form a complex condition for filtering data.
  • OR– introduce you to the OR operator and show you how to combine the OR operator with the AND operator to filter data.
  • IN – show you how to use the IN operator in the WHERE clause to determine if a value matches any value in a list or a subquery.
  • BETWEEN – show you how to query data based on a range using BETWEEN operator.
  • LIKE – provide you with technique to query data based on a specific pattern.
  • LIMIT – use LIMIT to constrain the number of rows returned by SELECT statement
  • IS NULL – test whether a value is NULL or not by using IS NULL operator.

Section 5. Joining tables

  • Table & Column Aliases – introduce you to table and column aliases.
  • Joins – give you an overview of joins supported in MySQL including inner join, left join, and right join.
  • INNER JOIN – query rows from a table that has matching rows in another table.
  • LEFT JOIN – return all rows from the left table and matching rows from the right table or null if no matching rows found in the right table.
  • RIGHT JOIN – return all rows from the right table and matching rows from the left table or null if no matching rows found in the left table.
  • CROSS JOIN – make a Cartesian product of rows from multiple tables.
  • Self-join – join a table to itself using table alias and connect rows within the same table using inner join and left join.

Section 6. Grouping data

  • GROUP BY – show you how to group rows into groups based on columns or expressions.
  • HAVING – filter the groups by a specific condition.
  • ROLLUP – generate multiple grouping sets considering a hierarchy between columns specified in the GROUP BY clause.

Section 7. Subqueries

  • Subquery – show you how to nest a query (inner query) within another query (outer query) and use the result of the inner query for the outer query.
  • Derived table – introduce you to the derived table concept and show you how to use it to simplify complex queries.
  • EXISTS – test for the existence of rows.

Section 8. Common Table Expressions

  • Common Table Expression or CTE – explain to you the common table expression concept and show you how to use CTE for querying data from tables.
  • Recursive CTE – use the recursive CTE to traverse the hierarchical data.

Section 9. Set operators

  • UNION and UNION ALL – combine two or more result sets of multiple queries into a single result set.
  • INTERSECT – show you a couple of ways to simulate the INTERSECT operator.
  • MINUS – explain to you the SQL MINUS operator and show you how to simulate it.

Section 10. Modifying data in MySQL

In this section, you will learn how to insert, update, and delete data from tables using various MySQL statements.

  • INSERT – use various forms of the INSERT statement to insert data into a table.
  • INSERT Multiple Rows – insert multiple rows into a table.
  • INSERT INTO SELECT – insert data into a table from the result set of a query.
  • INSERT IGNORE – explain you the INSERT IGNORE statement that inserts rows into a table and ignores rows that cause errors.
  • UPDATE – learn how to use UPDATE statement and its options to update data in database tables.
  • UPDATE JOIN – show you how to perform cross-table update using UPDATE JOIN statement with INNER JOIN and LEFT JOIN.
  • DELETE – show you how to use the DELETE statement to delete rows from one or more tables.
  • ON DELETE CASCADE – learn how to use ON DELETE CASCADE referential action for a foreign key to delete data from a child table automatically when you delete data from a parent table.
  • DELETE JOIN – show you how to delete data from multiple tables.
  • REPLACE – learn how to insert or update data depends on whether data exists in the table or not.
  • Prepared Statement – show you how to use the prepared statement to execute a query.

Section 11. MySQL transaction

  • Transaction – learn about MySQL transactions, and how to use COMMIT and ROLLBACK to manage transactions in MySQL.
  • Table locking – learn how to use MySQL locking for cooperating table access between sessions.

Section 12. Managing MySQL databases and tables

This section shows you how to manage the most important database objects in MySQL including databases and tables.

  • Selecting a MySQL database – show you how to use the USE statement to select a MySQL database via the mysql program and MySQL Workbench.
  • Managing databases – learn various statements to manage MySQL databases including creating a new database, removing an existing database, selecting a database, and listing all databases.
  • CREATE DATABASE – show you how to create a new database in MySQL Server.
  • DROP DATABASE – learn how to delete an existing database.
  • MySQL storage engines– it is essential to understand the features of each storage engine so that you can use them effectively to maximize the performance of your databases.
  • CREATE TABLE – show you how to create new tables in a database using CREATE TABLE statement.
  • MySQL sequence – show you how to use a sequence to generate unique numbers automatically for the primary key column of a table.
  • ALTER TABLE – learn how to use the ALTER TABLE statement to change the structure of a table.
  • Renaming table – show you how to rename a table using RENAME TABLE statement.
  • Removing a column from a table – show you how to use the ALTER TABLE DROP COLUMN statement to remove one or more columns from a table.
  • Adding a new column to a table – show you how to add one or more columns to an existing table using ALTER TABLE ADD COLUMN statement.
  • DROP TABLE – show you how to remove existing tables using DROP TABLE statement.
  • Temporary tables – discuss MySQL temporary table and show you how to manage temporary tables.
  • TRUNCATE TABLE – show you how to use the TRUNCATE TABLE statement to delete all data in a table fast.
  • Generated columns – learn how to use the MySQL generated columns to store data computed from an expression or other columns.

Section 13. MySQL data types

  • MySQL data types – show you various data types in MySQL so that you can apply them effectively in designing database tables.
  • INT – show you how to use integer data type.
  • DECIMAL – show you how to use DECIMAL datatype to store exact values in decimal format.
  • BIT – introduce you BIT datatype and how to store bit values in MySQL.
  • BOOLEAN – explain to you how MySQL handles Boolean values by using TINYINT(1) internally.
  • CHAR – a guide to CHAR data type for storing the fixed-length string.
  • VARCHAR – give you the essential guide to VARCHAR datatype.
  • TEXT – show you how to store text data using TEXT datatype.
  • DATE – introduce you to the DATE datatype and show you some date functions to handle the date data effectively.
  • TIME – walk you through the features of TIME datatype and show you how to use some useful temporal functions to handle time data.
  • DATETIME – introduce you to the DATETIME datatype and some useful functions to manipulate DATETIME values.
  • TIMESTAMP – introduce you to TIMESTAMP and its features called automatic initialization and automatic update that allows you to define auto-initialized and auto-updated columns for a table.
  • JSON – show you how to use JSON data type to store JSON documents.
  • ENUM – learn how to use ENUM datatype correctly to store enumeration values.
Format

Section 14. MySQL constraints

  • NOT NULL constraint – introduce you to the NOT NULL constraint and show you how to declare a NOT NULL column or add a NOT NULL constraint to an existing column.
  • Primary key constraint – guide you on how to use the primary key constraint to create the primary key for a table.
  • Foreign key constraint – introduce you to the foreign key and show you step by step how to create and drop foreign keys.
  • Disable foreign key checks – learn how to disable foreign key checks.
  • UNIQUE constraint – show you how to use UNIQUE constraint to enforce the uniqueness of values in a column or a group of columns in a table.
  • CHECK constraint – learn how to create CHECK constraints to ensure data integrity.
  • CHECK constraint emulation – if you use MySQL 8.0.15 or earlier version, you can emulate CHECK constraints using views or triggers.

Mysql Update

Section 15. MySQL globalization

  • Character Set – discuss character set and show you step by step how to perform various operations on character sets.
  • Collation – discuss collation and show you how to set character sets and collations for the MySQL server, database, tables, and columns.

Section 16. MySQL import & export

  • Import CSV File Into MySQL Table – show you how to use LOAD DATA INFILE statement to import CSV file into a MySQL table.
  • Export MySQL Table to CSV – learn various techniques of how to export MySQL table to a CSV file format.

Section 17. Advanced techniques

  • Natural sorting – walk you through various natural sorting techniques in MySQL using the ORDER BY clause.

The world’s most ubiquitous and flexible open source relational database

MySQL is the most widely adopted open source relational database and serves as the primary relational data store for many popular websites, applications, and commercial products. With more than 20 years of community-backed development and support, MySQL is a reliable, stable, and secure SQL-based database management system. The MySQL database is suitable for a wide variety of use cases, including mission critical apps, dynamic websites, and as an embedded database for software, hardware, and appliances.
AWS supports MySQL in a variety of ways, including a fully managed database service, Amazon Relational Database Service (RDS) for MySQL. Amazon Aurora with MySQL compatibility is also built using MySQL, and Amazon RDS supports the popular MySQL fork project, MariaDB. You can also host MySQL on Amazon EC2 and self-manage the database, or browse the 3rd party MySQL offerings on AWS Marketplace.

History of MySQL

The first version of MySQL Server was released in 1995 by the Swedish company MySQL AB, founded by David Axmark, Allan Larsson, and Michael Widenius. MySQL takes its name from Widenius’ daughter, named My. The MySQL project was released as open source in 2000, under the GNU General Public License (GPL). By 2001, MySQL had reached more than 2 million active installations; by 2004, the software was being downloaded more than 30,000 times a day. MySQL was acquired by Sun Microsystems in 2008 and, when Oracle acquired Sun in 2009, it also took ownership of MySQL. Today, MySQL is the most widely used open source relational database system.

Ease-of-use and performance

MySQL database has found favor with web developers due to its ease-of-use and productivity features, including triggers, stored procedures, and updatable views. MySQL includes utilities like mysqldump, a backup program; mysqladmin, an administrative client; and MySQL Workbench, a GUI for management and migration work.

Over time, MySQL has boosted its performance capabilities with features including B-tree disk tables with index compression, thread-based memory allocation, and optimized nested-loop joins. Row-level locking and consistent reads in the storage engine give MySQL additional performance benefits for multi-user concurrency.

Reliability and security

MySQL’s InnoDB transactional storage engine adheres to the ACID model, with capabilities that improve data protection, including point-in-time recovery and autocommit. InnoDB offers additional data integrity through support for foreign key constraints, preventing data inconsistencies across tables.
MySQL includes hardened and flexible security features, including host-based verification and encryption of password traffic. InnoDB offers additional security benefits, with data-at-rest tablespace encryption using a two-tier encryption key architecture.

Open source license

MySQL is available under an open source license (the GNU General Public License) allowing you to freely use and modify the source code. Managed versions of MySQL, like Amazon RDS for MySQL, carry no additional licensing costs.
MySQL’s large, global community of contributors and enthusiasts bring many additional and long-tail benefits to using the database system. For example, the MySQL community stays on top of security issues and bug fixes, contributing to the overall resilience of the software. MySQL user groups, events, forums, and mailing lists provide a built-in network for education and support.

General purpose OLTP database

MySQL is suitable for any application requiring a transactional SQL engine, including mission-critical apps and heavy trafficked websites. MySQL adheres to ACID principles and includes extensions to ANSI/ISO Standard SQL, as well as support for XML and JSON. MySQL also supports high-availability database clustering, and can handle terabyte-sized databases. Popular applications that use the MySQL database include TYPO3, MODx, Joomla, WordPress, phpBB, MyBB, and Drupal.

eCommerce applications

MySQL is one of the most popular transactional engines for eCommerce platforms. MySQL is particularly useful for managing customer data, transactions, and product catalogs. In eCommerce solutions, MySQL is often used in conjunction with other, non-relational databases, including document and key-value stores for syncing order data, and storing non-product data.

LAMP open source stack

MySQL is integral to countless applications running on the LAMP open source software stack (LAMP stands for Linux, Apache, MySQL, and PHP/Python/Perl). LAMP is a ubiquitous web services solution stack and is widely considered the platform of choice for dynamic websites and high-performance web applications.

MariaDB

MariaDB is a popular fork of MySQL from MariaDB, which was founded by the original developers of MySQL who intended it to remain free and open source under the GNU GPL. While MariaDB is maintained separately from MySQL, it retains a high degree of MySQL compatibility, including library binary equivalency, and exact matching with APIs. AWS supports MariaDB with the fully managed database service, Amazon RDS for MariaDB.

Percona Server

Percona Server is another popular fork of MySQL from Percona. Percona Server includes XtraDB, Percona's fork of the InnoDB Storage Engine.

Language support

MySQL supports most leading programming languages and protocols, including:

MySQL vs. PostgreSQL

MySQL and PostgreSQL are both popular open source relational databases. Traditionally, MySQL has been perceived as easy to use and fast, whereas PostgreSQL has been perceived as feature-rich and more comparable to commercial databases like Oracle. However, the current major versions of MySQL and PostgreSQL both offer many robust features and capabilities in the way of performance, reliability, security, and more. You can learn more about PostgreSQL and try Amazon RDS for PostgreSQL using the AWS Free Tier.

MySQL Hosting Options on AWS

Self-managed MySQL on Amazon EC2

Mysql Workbench Download Latest Version

Historically, relational databases have been on-premises, and as database workloads moved to the cloud, organizations initially leveraged Amazon EC2 to run their own databases. With this approach, you have to manage all of the usual administration tasks that accompany an on-premises database such as hardware provisioning, database setup, tuning, patching, backups, and scaling.

Fully Managed MySQL on Amazon RDS

Amazon offers a fully managed relational database service, Amazon RDS for MySQL, available for trial at no cost with the AWS Free Tier. Amazon RDS makes it easy to set up, operate, and scale MySQL deployments in the cloud. With Amazon RDS, you can deploy internet-scale MySQL deployments in minutes, with cost-efficient and resizable hardware capacity.
Getting started with Amazon RDS for MySQL is simple:
Discover how to create and connect to a MySQL database using RDS.
Begin building with help from the MySQL on Amazon RDS user guide.
Sign up for the Amazon RDS free tier

Mysql Download

Have more questions?

Mysql Installer

Contact us