MySQL is an open-source relational database management system (RDBMS). Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language.
This 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 a Database?
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 example of MySQL query looks like this:
SELECT EMP_NAME, FROM EMPLOYEE WHERE EMP_ID=200 AND EMP_COUNTRY=”INDIA”
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.
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.
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
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
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.
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 webserver 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.
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.