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. MySQL is named after co-founder Monty Widenius's daughter: My; The data in a MySQL database are stored in tables. A table is a collection of related data, and it consists of columns and rows. Databases are useful for storing information categorically. A company may have a database with the following tables: Employees.
MySQL Database Service is the only MySQL cloud service with an integrated, high-performance analytics engine that enables customers to run sophisticated analytics directly against their operational MySQL databases, eliminating the need for complex, time-consuming, and expensive data movement and integration with a separate analytics database. MySQL Training and Tutorials. With our in-depth MySQL how-to videos, you can learn to use MySQL and PHP together, explore the fundamentals of CRUD (create, read, update, and delete), and then dive into details like how to join tables and install WampServer, MAMP, and XAMPP.
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
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
Fully Managed MySQL on Amazon RDS
This MySQL tutorial explores all of the comparison operators used to test for equality and inequality, as well as the more advanced operators.
Description
Comparison operators are used in the WHERE clause to determine which records to select. Here is a list of the comparison operators that you can use in MySQL:
Comparison Operator | Description |
---|---|
= | Equal |
<=> | Equal (Safe to compare NULL values) |
<> | Not Equal |
!= | Not Equal |
> | Greater Than |
>= | Greater Than or Equal |
< | Less Than |
<= | Less Than or Equal |
IN ( ) | Matches a value in a list |
NOT | Negates a condition |
BETWEEN | Within a range (inclusive) |
IS NULL | NULL value |
IS NOT NULL | Non-NULL value |
LIKE | Pattern matching with % and _ |
EXISTS | Condition is met if subquery returns at least one row |
Let's review the comparison operators that you can use in MySQL.
Example - Equality Operator
In MySQL, you can use the =
operator to test for equality in a query. The =
operator can only test equality with values that are not NULL.
For example:
In this example, the SELECT statement above would return all rows from the contacts table where the last_name is equal to Johnson.
Example - Equality Operator (Safe with NULL Values)
Because the =
operator only compares non-NULL values, it is not safe to use with NULL values. To overcome this limitation, MySQL added the <=>
operator to allow you to test for equality with both NULL and non-NULL values.
To better explain the difference between the =
operator and the <=>
operator, we will include some examples with both queries and data.
Assuming that we have a table called contacts in MySQL that is populated with the following data:
contact_id | last_name | website1 | website2 |
---|---|---|---|
1 | Johnson | techonthenet.com | <NULL> |
2 | Anderson | <NULL> | <NULL> |
3 | Smith | TBD | TDB |
4 | Jackson | checkyourmath.com | digminecraft.com |
We could use the =
operator in the following query:
Because we used the =
operator, we would get the following results:
contact_id | last_name | website1 | website2 |
---|---|---|---|
3 | Smith | TBD | TDB |
In this example, the SELECT statement above would return all rows from the contacts table where the website1 is equal to website2. It does not return the second record where website1 and website2 are both NULL values.
Now let's see what happens when we rewrite our query using the <=>
operator that is safe to use with NULL values:
Because we used the <=>
operator, we would get the following results:
contact_id | last_name | website1 | website2 |
---|---|---|---|
2 | Anderson | <NULL> | <NULL> |
3 | Smith | TBD | TDB |
Now our query returns all rows from the contacts table where website1 is equal to website2, including those records where website1 and website2 are NULL values.
Example - Inequality Operator
In MySQL, you can use the <>
or !=
operators to test for inequality in a query.
For example, we could test for inequality using the <>
operator, as follows:
In this example, the SELECT statement would return all rows from the contacts table where the last_name is not equal to Johnson.
Or you could also write this query using the !=
operator, as follows:
Both of these queries would return the same results.
Example - Greater Than Operator
You can use the >
operator in MySQL to test for an expression greater than.
Mysql Workbench
In this example, the SELECT statement would return all rows from the contacts table where the contact_id is greater than 50. A contact_id equal to 50 would not be included in the result set.
Example - Greater Than or Equal Operator
In MySQL, you can use the >=
operator to test for an expression greater than or equal to.
In this example, the SELECT statement would return all rows from the contacts table where the contact_id is greater than or equal to 50. In this case, contact_id equal to 50 would be included in the result set.
Example - Less Than Operator
You can use the <
operator in MySQL to test for an expression less than.
In this example, the SELECT statement would return all rows from the inventory table where the product_id is less than 300. A product_id equal to 300 would not be included in the result set.
Mysql Create User
Example - Less Than or Equal Operator
In MySQL, you can use the <=
operator to test for an expression less than or equal to.
In this example, the SELECT statement would return all rows from the inventory table where the product_id is less than or equal to 300. In this case, product_id equal to 300 would be included in the result set.
Example - Advanced Operators
Mysql Count
We've written specific tutorials to discuss each of the more advanced comparison operators. These topics will be covered later, or you can jump to one of these tutorials now.