MySQL
- Pronunciation
- my-ES-kyoo-EL
In short
MySQL is a popular open-source relational database queried with SQL, long known as the database behind WordPress and the classic LAMP web stack.
What is MySQL?
MySQL was first released in 1995 by the Swedish company MySQL AB. Sun Microsystems bought it in 2008, and Oracle took it over when it acquired Sun in 2010. It is a relational database management system: data is organized in tables with rows and columns, and applications read and change it with SQL.
It became famous as the M in the LAMP stack, Linux, Apache, MySQL and PHP, which powered a large part of the early web. WordPress, Drupal and many other content management systems still use it by default, and almost every web host offers it. Its default storage engine, InnoDB, supports transactions, row-level locking and foreign keys.
MySQL is valued for being easy to install, fast for common read-heavy workloads and supported by every major language and cloud. It can replicate data from a primary server to read replicas, which is a common way to scale reads. Large sites run it at enormous scale with tools that shard data across many servers.
A common misconception is that MySQL and MariaDB are the same product. MariaDB is a fork started in 2009 by MySQL's original creator, and the two have drifted apart over the years, although they remain largely compatible. MySQL itself is available both under the GPL open-source license and under commercial licenses from Oracle.
Key takeaways
- MySQL is an open-source relational database that uses SQL.
- It is the M in the classic LAMP stack and the default for WordPress.
- The InnoDB engine provides transactions, row locking and foreign keys.
- Read replicas are a common way to scale MySQL.
- MariaDB is a separate fork made by MySQL's original creator.
Example
CREATE TABLE posts (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(200) NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB;
INSERT INTO posts (title) VALUES ('Hello, world');
SELECT id, title FROM posts ORDER BY created_at DESC LIMIT 10;Readers ask
Is MySQL free?
The MySQL Community Edition is free and open source under the GPL. Oracle also sells commercial editions with extra features and support.
What is the difference between MySQL and MariaDB?
MariaDB is a fork of MySQL created in 2009 by Michael Widenius, one of MySQL's founders. It started as a drop-in replacement, and while the two are still largely compatible, each now has features the other lacks.
Is MySQL a NoSQL database?
No. MySQL is a relational SQL database, although it can store and query JSON columns for more flexible data.
Often compared
See also
- Relational DatabaseDatabases, p. 38A relational database stores data in tables of rows and columns, links those tables through keys, and lets you query and combine the data with SQL.
- SQLDatabases, p. 40SQL is the standard language for working with relational databases, used to create tables and to insert, query, update, and delete the data stored in them.
- PostgreSQLDatabases, p. 35PostgreSQL is a free, open-source relational database known for reliability, strict standards support and extensions, and widely used for web applications.
- Database ReplicationDatabases, p. 10Database replication is the continuous copying of data from one database server to others, so several servers hold the same data for reliability and scale.
- DatabaseDatabases, p. 6A database is an organized collection of data stored on a computer, managed by software that lets applications save, search, and update it efficiently.
- PHPProgramming Languages, p. 23PHP is a dynamically typed scripting language designed for web development that runs on the server to generate HTML pages and respond to browser requests.
Spotted a mistake or something missing on this page?Suggest an edit