What is MySql and how does it store data?
Author: Domeny.ForSale editorial team Published
In brief: MySQL is a relational database management system: software that stores structured information and lets you read and change it. Websites, online shops and applications use it to store things such as posts, user accounts and orders. MySQL is not a programming language: it primarily uses SQL to work with data.
How does MySQL store data?
A relational database organizes information into tables. Each table has columns defining the types of data and rows representing individual records, such as customers. Tables can be linked using identifiers, rather than storing the same information repeatedly.
In an online shop, the customers table might contain an identifier, first name and email address. The orders table stores the order number, amount and customer identifier. This link makes it possible to find all of one person’s orders without copying their details into every record.
MySQL does more than store data. It also controls permissions, supports multiple users working at the same time, and executes queries: commands that retrieve or change data. Indexes—supporting structures similar to the index in a book—can speed up searches without scanning the entire table.
How does MySQL differ from SQL and other databases?
SQL is a language for writing commands, while MySQL is a program that executes them. SQL is used to create tables, add records and select information that meets specific conditions, among other tasks. Other database systems use it too, although syntax details and available features may differ.
Here is an example query for the customers table:
SELECT first_name, email
FROM customers
WHERE city = 'Kraków';
The command retrieves the first names and email addresses of customers whose city field contains Kraków. It does not change any data. On a typical website, application code runs these queries, so the website owner does not have to enter them manually.
MySQL is sometimes confused with MariaDB. They are separate systems with shared roots, compatible in many uses but not identical. Before switching from one to the other, check the application’s requirements and the compatibility of the specific versions. PostgreSQL is another separate system, while SQLite usually runs as a library using a local file, without a separate database server.
What does MySQL do on a website?
MySQL often provides the database behind a CMS, or content management system. One example is WordPress, which can use MySQL or MariaDB. It stores post content, settings, comments and user information in the database, among other things.
A database is not the same as hosting or a complete website, however. Hosting provides the environment in which the website runs, and MySQL is one of the services available within it. Application code, themes and uploaded photos are usually stored in files, though the database may store information about their locations.
When someone opens a blog post, the application retrieves its content from the database and prepares the page for the browser. Caching can reduce the number of these reads. The browser itself usually does not connect directly to MySQL—the application running on the server does that.
Not every website needs a database. A simple website made from ready-made HTML files can run without MySQL. A database becomes useful when information needs to be regularly edited, filtered or saved by users.
Is MySQL free, and how do you get started?
MySQL Community Edition is available without a licence fee under the GPL licence. Commercial MySQL offerings also exist. Having no licence fee for this edition does not mean it costs nothing to run: you may still pay for a server, administration, backups or a managed service.
When setting up WordPress on shared hosting, you usually do not need to install MySQL yourself. An automatic installer can set up the database and connection. Manual configuration generally involves these steps:
- Create a database in the hosting control panel.
- Create a database user and grant the required permissions.
- Enter the database name, username, password and database server address in the application’s installer.
- Check that the website works and how backups are made.
phpMyAdmin is often used to browse tables and run queries. It is an administration interface, not the database itself. Changes made through it can affect the website directly. Before editing data manually, make a backup that you know how to restore.
What should you check when choosing hosting with MySQL?
A claim of “MySQL support” alone is not enough to assess an offer. Check the application’s documentation for the required versions, and confirm with the hosting provider which system and version it actually provides. Also ask about limits on database size and simultaneous connections, and whether you can export your data.
Backup policies matter: how often backups are made, how long they are kept and how they are restored. A backup of WordPress files alone does not include content stored in the database, and a database backup alone does not replace the website’s photos and other files.
Security also depends on the application. It should use parameterized queries, which separate user data from SQL commands and help prevent the injection of malicious instructions. Database credentials must not appear in publicly accessible website code or a public repository.
If you are setting up a ready-made CMS, start by checking its requirements and whether your hosting provider supports restoring backups. Learning SQL can come later; a working connection and the ability to recover your data are needed from the start.
See also: What is 2FA?
