MySQL is a free, open-source database management system. WordPress uses it to store and fetch everything from your posts to your plugin settings.
You don't have to learn it to run a blog. Still, knowing the basics comes handy when you install WordPress, move to a new host or fix a database error.
What is MySQL?
MySQL is a relational database. It keeps data in tables made of rows and columns, a bit like a set of spreadsheets that are linked to each other. Programs talk to it using SQL, which stands for Structured Query Language.
WordPress is written in PHP. Whenever a visitor opens a page, PHP sends a query to MySQL, gets the content back and builds the page.
MySQL vs MariaDB
MariaDB started as a fork of MySQL, created by some of its original developers. It works as a drop-in replacement, so WordPress runs on either one without any changes. Plenty of hosts now use MariaDB, even when the control panel still calls it MySQL.
WordPress needs a reasonably recent version of one of them. You can check the details in our post on minimum WordPress server requirements.
How to create a MySQL database for WordPress
Most hosts install WordPress for you, but here is how to set up a database by hand in a typical control panel:
- First, log in to your hosting control panel and open the MySQL Databases section.
- Next, create a new database and give it a name.
- Now, create a database user with a strong password.
- Here, add the user to the database and grant All Privileges.
- Finally, enter these details when the WordPress installer asks for them.
If you prefer the command line, see how to create a database in MariaDB.
The "Error establishing a database connection" message usually means WordPress cannot reach the MySQL server. Common causes are wrong login details in wp-config.php or a database server that is down.
That's all about MySQL, the quiet engine room behind every WordPress site. If you have any doubts, leave a comment below and we will reply.