MySQL is an open source SQL relational database management system that’s developed and supported by Oracle.

That’s the short, one sentence answer to the question of “what is MySQL”, but let’s break that down into terms that are a little more human-friendly.

A database is just a structured collection of data that’s organized for easy use and retrieval. For a WordPress site, that “data” is stuff like the text of your blog posts, information for all the registered users at your site, autoloaded data, important settings configurations, etc.

MySQL is just one popular system that can store and manage that data for you, and it’s an especially popular database solution for WordPress sites.

Let’s get a little deeper into the question now.

What is MySQL? In More Detail

MySQL was originally launched all the way back in 1995. Since then, it’s gone through a couple of changes in ownership/stewardship, before ending up at the Oracle Corporation in 2010. While Oracle is in charge now, MySQL is still open source software, which means that you can freely use and modify it.

MySQL logo

MySQL logo (Image source: MySQL/Oracle)

The name comes from putting together “My” – the name of the co-founder’s daughter – with SQL – the abbreviation of Structured Query Language, which is a programming language that helps you access and manage data in a relational database.

In order to understand how MySQL works, it’s important to know two connected concepts:

Relational Databases

When it comes to storing data in a database, there are different approaches that you can use.

MySQL opts for an approach called a relational database.

With a relational database, your data is broken up into multiple separate storage areas – called tables – rather than throwing everything together into one big storage unit.

For example, let’s say you want to store two types of information:

  • Customers – their name, address, details, etc.
  • Orders – like which products were purchased, the price, who made the order, etc.

If you tried to lump all that data together into one big pot, you’d have a few problems like:

  • Different data – the data that you need to collect for an order is different than that for a customer.
  • Duplicate data – each customer has a name, and each order also has the name of a customer. Handling that duplicate data gets messy.
  • No organization – how do you reliably connect order information to customer information?

To solve those problems, a relational database would use one separate table for customers, and another separate table for orders.

However, you’d probably also want to be able to say “show me all the orders for John Doe”. That’s where the relational part comes in.

Using something called a “key”, you’re able to link the data from these two tables together so that you can manipulate and combine the data in different tables as needed. It’s important to note that a key is not the customer’s name. Instead, you’d use something 100% unique, like a numerical ID number.

If you’ve ever looked at your WordPress site’s database, you’ll see that it uses this relational model, with all of your data divided into separate tables.

By default, WordPress uses 12 separate tables, but many WordPress plugins will also add their own tables. For example, the database for the WordPress site below has 44 separate tables!

An example of different tables in MySQL

An example of different tables in MySQL

To finish out this relational concept, let’s make it specific to WordPress…

WordPress stores blog posts in the wp_posts table and users in the wp_users table. However, because those two tables are connected by a key, you’re able to link each user account with all of the blog posts that each user has written.

Here’s how that looks in the database.

Each post is assigned a post_author, which is a unique identifying number (this is the key):

The wp_posts table

The wp_posts table

Then, if you want to see which user account corresponds to that number, you could look at the ID in the wp_users table:

The wp_users table

The wp_users table

The key – the ID number – is what connects everything together. And that’s how they’re “related” to each other, despite storing the data in separate tables.

Client-Server Model

Beyond being a relational database system, MySQL also uses something called the client-server model.

The server part is where your data actually resides. In order to access this data, though, you need to request it. That’s where the client comes in.

Using SQL – the programming language we mentioned earlier – the client sends a request to the database server for the data that the client needs.

Struggling with downtime and WordPress problems? Kinsta is the hosting solution designed to save you time! Check out our features

For example, if someone visits a blog post on your site, your WordPress site will send multiple SQL requests to the database server to get all the information it needs to deliver the blog post to that visitor’s web browser. It would:

  • Query the wp_posts table to get the content for the blog post
  • Query the wp_users table to get information for the author box (using the key we showed you above)
  • Etc.

If you want to see exactly what types of database requests are being made by your WordPress site, you can use a wonderful free plugin called Query Monitor to see the exact interplay between your WordPress site (the client) and the database server:

The Query Monitor plugin shows you individual SQL queries sent to the MySQL server

The Query Monitor plugin shows you individual SQL queries sent to the MySQL server

Another premium solution you can use is New Relic. Our engineers use this tool frequently to troubleshoot performance issues on a WordPress site that might be due to a slow MySQL query.

The New Relic databases page shows slow database tables.

If your WordPress site can’t access the database server, it triggers the common error establishing a database connection message.

Kinsta Uses MariaDB, Not MySQL: What’s the Difference?

Here at Kinsta, we use a database system called MariaDB, not MySQL. However, all the same characteristics you saw with MySQL also apply to MariaDB.

In fact, MariaDB is actually a fork of MySQL, and MariaDB’s lead developer is one of the original founders of MySQL. A “fork” just means that the MariaDB developers took the original open-source MySQL code as their base and then built upon that to create MariaDB.

So while it has a different name, MariaDB is tightly linked to MySQL and offers full “drop-in” replacement capability (that is, you can seamlessly switch from MySQL to MariaDB without needing to take any special precautions).

However, while MariaDB does offer interoperability with MySQL, it also offers improved performance in some areas, which fits with our philosophy of using the best-performing architecture to power your WordPress site.

Kinsta uses MariaDB, a fork of MySQL, to ensure the best performance for your WordPress site. 🚀 Click to Tweet

Recap: What is MySQL?

MySQL is an open source relational database management system. For WordPress sites, that means it helps you store all your blog posts, users, plugin information, etc.

It stores that information in separate “tables” and connects it with “keys”, which is why it’s relational.

When your WordPress site needs to access that information, it sends a request to the MySQL database server using SQL (this is the client-server model).

Kinsta uses MariaDB, not MySQL. However, MariaDB is a fork of MySQL from one of the co-founders of MySQL and offers drop-in replacement interoperability, as well as some performance improvements. As such, all of the core concepts in this article also apply to MariaDB.

If you host at Kinsta, we offer both direct database access, as well as the ability to use database management tools like phpMyAdmin.

5.3K
Shares