Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

What is: MySQL

MySQL is the database management system used by WordPress to store and retrieve your blog information. It acts as a filing cabinet for your website and is pronounced ‘my sequel’.

The database application is currently owned by Oracle Corporation and is open source software licensed under the GPL and available for free.

While you can use WordPress without knowing how to use MySQL, a basic understanding can help you troubleshoot problems with your WordPress site.

What Is MySQL?

What Is a Database?

MySQL is a relational database management system that’s capable of handling multiple users and databases. It runs as a server and is installed on your WordPress hosting server.

Think of it as a digital filing cabinet that organizes and stores all of the data on your website.

Information is retrieved, added, and deleted from tables in the database using a special programming language called SQL, or Structured Query Language. A SQL instruction to retrieve data is known as a query.

A typical MySQL query looks like this:

SELECT * FROM wp_posts WHERE ID = 23;

You don’t need to understand how databases work or learn the SQL language to use WordPress. All of this happens automatically behind the scenes. However, a knowledge of MySQL can help with troubleshooting.

You can fix many WordPress errors by working directly with the database, especially when you’re unable to log in to the WordPress admin area. For example, you can reset a WordPress password, add an admin user, and change the WordPress email address.

You can access your MySQL database using phpMyAdmin. This is a web application that lets you manage MySQL databases using a web browser. You’ll find it in your web hosting provider’s control panel.

phpMyAdmin

To learn more about databases and how to use them, see our beginners guide on WordPress database management with phpMyAdmin.

How Does WordPress Use MySQL?

WordPress stores a great deal of information in a database, including posts, pages, comments, categories, tags, custom fields, users, and other WordPress settings.

That’s why, when you first install WordPress, it asks you to provide a database name, host, username, and password.

Provide a Database Name, Host, Username and Password

This information is stored in the configuration file called wp-config.php.

During the installation, WordPress uses the information you provide about the database to create tables and store default installation data inside those tables.

Each WordPress installation starts with 12 default tables in the database. These contain data for different sections, features, and functionality of WordPress.

Currently, a default WordPress installation creates the following tables:

  • wp_commentmeta contains meta information about comments
  • wp_comments contains comments and the comment author’s details
  • wp_links manages blogrolls created by earlier versions of WordPress
  • wp_options contains most of the site wide WordPress settings
  • wp_postmeta contains meta information about posts, pages, and custom post types
  • wp_posts contains your posts, pages, custom post types, and revisions
  • wp_termmeta contains metadata for terms under custom taxonomies
  • wp_terms contains terms under taxonomies, such as each category and tag
  • wp_term_relationships manages the relationships between post types and terms
  • wp_term_taxonomy defines taxonomies to differentiate between categories and tags
  • wp_usermeta contains meta information about registered users
  • wp_users contains user information including usernames and passwords

The wp_ before each table name is the default database prefix. You might like to choose a different prefix during the WordPress installation to improve the security of your website.

Because your WordPress content is stored in MySQL, your website backup solution will need to make a copy of your database tables as well as the files stored in your media library, themes and plugins.

Backup plugins such as Duplicator will automatically send complete backups of your WordPress files and database to a remote location. You can learn how to set it up by following our guide on how to backup your WordPress website.

How MySQL Affects Website Performance

MySQL runs on your web server as an application, so requires more resources when more users visit your website. That’s because each time a user visits your website, WordPress has to fetch the information from the database before the web page is sent to the user’s browser.

This makes your website load slower when a lot of users are visiting it at the same time.

Most websites address this by using a WordPress caching plugin. These plugins store frequently requested web pages so that your database doesn’t have to be queried as often. As a result, your website runs faster.

WordPress Caching Plugin

We recommend using either WP Rocket (premium) or WP Super Cache (free). Many WordPress hosting companies like Bluehost and SiteGround offer caching solutions as well.

You can follow our guide on how to install and set up WP Super Cache on your WordPress site to see how easy it is to add a caching solution to your website.

Running MySQL on Your Computer

If you wish to run WordPress locally on your computer, then you will need to run the same software as your WordPress hosting provider. This includes Apache (the web server software), MySQL (the database) and PHP (the programming language).

Luckily, software stacks like WAMP (for Windows), MAMP (for Mac), LAMP (for Linux) and XAMPP (cross platform) makes installation easy.

WAMP Allows You to Run WordPress on Your Windows Computer

We hope this article helped you learn more about MySQL in WordPress. You may also want to see our Additional Reading list below for related articles on useful WordPress tips, tricks, and ideas.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Additional Reading

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!