MySQL is an open-source relational database that most website software uses to store its content.

MySQL is a database system that stores information in tables made of rows and columns, a bit like a set of linked spreadsheets. Website software uses it to keep anything that changes: posts, pages, users, orders, comments and settings.

Take a WordPress blog. The text of each post lives in a table called wp_posts, user accounts in wp_users, and comments in wp_comments. When someone opens a post, WordPress asks MySQL for the right row and builds the page from it.

How MySQL works

Your application talks to MySQL using SQL (Structured Query Language). A query like SELECT title FROM wp_posts WHERE id = 42 asks for one piece of data, and MySQL returns it. Behind the scenes MySQL uses indexes to find rows quickly, much like the index in a book, and a storage engine (usually InnoDB) to write data safely to disk.

Each database has its own users and passwords, and you give your application those details in its config file, such as wp-config.php for WordPress.

MySQL vs MariaDB

MariaDB is a fork of MySQL created by some of MySQL's original developers. It's designed as a drop-in replacement, so software written for MySQL almost always runs on MariaDB without changes. Many hosts run MariaDB and still call it MySQL in their control panel, and for everyday website use the difference rarely matters.

Why MySQL matters for your website's speed

On a dynamic site, the database is often the slowest part of building a page. A few things make a big difference:

  • Fast storage, such as NVMe drives, so reads and writes don't wait on the disk.
  • An object cache like Redis, so repeated queries are answered from memory.
  • Indexes on columns your queries search by.
  • Cleaning up bloat, such as old revisions, spam comments and expired transients.

Common MySQL problems

  • "Error establishing a database connection": usually wrong credentials in the config file, or the database server is overloaded.
  • Slow queries from badly written plugins or missing indexes.
  • Corrupted tables after a crash, which can often be repaired from phpMyAdmin or the control panel.
  • Hitting limits, such as maximum connections, on a busy site.

How to manage a MySQL database

Most hosting control panels, including cPanel, let you create databases and users and open phpMyAdmin to browse tables, run queries, and import or export backups. Developers can also use the command line over SSH with tools like mysqldump.

MySQL questions

Is MySQL free to use?
Yes. MySQL Community Edition is free and open source, and it's included with most web hosting plans at no extra cost.
Does WordPress need MySQL?
Yes. WordPress needs a MySQL or MariaDB database to store its posts, pages, users and settings.
How do I back up a MySQL database?
Export it from phpMyAdmin or run mysqldump over SSH to create a .sql file. Most hosts also include databases in their automatic backups.
Was this definition helpful?
Share this definition