MySQL online course

What Is MySQL?

Learn what MySQL is, how relational databases and SQL work, common uses, LAMP stack context, administration tools, licensing, and MySQL alternatives.

MySQL is a relational database management system, or RDBMS. It is software that stores, organizes, retrieves, and manages structured data. Web applications, content management systems, forums, and many other programs can use MySQL to save information and query it later.

A database is an organized collection of data. MySQL is not the data collection itself; it is the database server software that manages one or more databases. Applications communicate with the MySQL server to create data, read it, update it, and remove it.

Database and RDBMS Fundamentals

A database management system (DBMS) is software used to create, store, retrieve, update, and administer databases. A DBMS can control access, process queries, and help applications work with persistent data.

MySQL is a relational database management system (RDBMS). The relational model represents data in related tables. Each table has a name and contains:

  • Columns: named attributes or fields shared by records, such as name, email, or city.
  • Rows: individual records in a table. One row might represent one customer or one order.

Tables can be connected through shared values and keys. For example, a users table might identify each user with a user ID, while an articles table stores the ID of the article's author. This relationship lets an application connect an article to its author without repeating all of the author's information in every article row.

Relational organization makes application data easier to query and helps maintain consistency. Instead of keeping unrelated information in one large, unstructured file, an application can store users, products, orders, and comments in suitable tables and connect them when needed.

ConceptWhat it isExample
DatabaseAn organized collection of data.A store of customer records.
DBMSSoftware used to create, store, retrieve, update, and administer databases.Software that manages database files and requests.
RDBMSA DBMS based on data organized into related tables.MySQL.
MySQLA relational database management system used to manage structured data.A server holding application databases.
SQLStructured Query Language, used to work with relational databases.SELECT retrieves rows.
TableA named structure that stores related records in rows and columns.customers.
RowOne record in a table.One customer's details.
ColumnA named attribute or field shared by records.city.
QueryAn instruction sent to a database, commonly to retrieve or change data.A request for customers in one city.

MySQL and SQL

SQL means Structured Query Language. It is the language used to define relational database structures, query data, insert records, change records, delete records, and control access.

MySQL and SQL are not the same thing. MySQL is an RDBMS that implements SQL. SQL is also used by other products, including Oracle Database and Microsoft SQL Server. SQL knowledge is therefore transferable, although syntax, functions, data types, tools, capabilities, and administration practices can vary between products.

Common categories of SQL work include:

  • Querying: retrieving data with commands such as SELECT.
  • Inserting: adding records with INSERT.
  • Changing: modifying existing records with UPDATE.
  • Deleting: removing records with DELETE.
  • Defining structures: creating or modifying databases and tables with commands such as CREATE and ALTER.

See SQL command syntax for a closer look at the structure of SQL statements.

A Simple MySQL Query

The following query asks for the names of customers who live in Berlin:

SELECT name FROM customers WHERE city = 'Berlin';
  • SELECT tells the database to retrieve data.
  • name is the column to return.
  • FROM identifies the table that supplies the records.
  • customers is the table name.
  • WHERE filters rows using a condition.
  • city is the column tested by that condition.
  • 'Berlin' is a string value. The quotation marks indicate text.
  • The semicolon marks the end of the SQL statement.

This statement reads the name column from the customers table, but only for rows whose city value is Berlin. It is an illustrative query; it assumes that a suitable table and columns already exist. You can continue with querying a database and advanced SELECT statements.

How MySQL Is Used

MySQL is frequently used as the data layer for web applications. A site might store user accounts, posts, products, orders, comments, settings, and session-related application data in MySQL tables.

For example, a content site could use tables for users, articles, comments, and categories. Relationships can associate each article with its author and associate comments with both an article and a commenter. The application sends SQL requests to read or change this information.

MySQL is associated with widely used content management systems, forums, and web platforms, including WordPress, phpBB, Joomla, and Drupal. It is a common choice, not the only suitable database solution. The best choice depends on an application's data model, scale, features, compatibility requirements, and operational needs.

MySQL in the LAMP Stack

LAMP is commonly expanded as Linux, Apache, MySQL, and PHP:

  • Linux is the operating system.
  • Apache is the web server.
  • MySQL is the database component.
  • PHP is the programming language used by many applications in this stack.

In a LAMP application, a browser request can reach Apache, PHP can run application logic, and the application can send SQL requests to MySQL. MySQL is not limited to LAMP, however. It can run with other operating systems, web servers, programming languages, and application architectures.

Open-Source Licensing and Availability

MySQL is open-source software, and its community distribution is available under the GNU General Public License (GPL). In beginner-level terms, open-source software has source code available under terms that permit specified forms of use, sharing, and modification. The GPL also sets conditions that users and distributors must follow.

This does not mean that every MySQL distribution, add-on, or commercial support offering has identical licensing conditions. Review the license that applies to the particular package or service you plan to use.

Ways to Access and Administer MySQL

MySQL can be operated through a command-line client, which is a text-based interface for connecting to a server and entering SQL statements. It can also be managed through a GUI, or graphical user interface, such as a graphical database administration or query tool.

Typical administration activities include:

  • Connecting to a MySQL server.
  • Creating databases and users.
  • Running queries.
  • Importing and exporting data.
  • Managing permissions and access.

A GUI can make these tasks more convenient, but it does not replace understanding SQL, tables, keys, permissions, and database behavior. The same database can be accessed from a terminal client or from a graphical query editor. Start with accessing MySQL or starting the command-line interface.

Operating System Support

MySQL is available across major operating-system families, including Windows, Linux, macOS, Solaris, and FreeBSD. Installation commands, file locations, service-management tools, and default configuration details differ by platform. For example, Linux and Windows have different installation and service procedures; follow the instructions appropriate to the operating system in use.

See the guides for installing MySQL on Linux and installing MySQL on Windows when you are ready to set up a server.

MySQL Compared with Other RDBMS Products

MySQL is one member of the broader RDBMS category. Oracle Database and Microsoft SQL Server are other database systems that use SQL and support relational data concepts.

ProductCategoryRelationship to SQL
MySQLRelational database management system.Implements SQL with MySQL-specific syntax, tools, and features.
Oracle DatabaseRelational database management system.Uses SQL with Oracle-specific syntax, tools, and features.
Microsoft SQL ServerRelational database management system.Uses SQL with SQL Server-specific syntax, tools, and features.

These products share important ideas such as tables, rows, columns, relationships, queries, and SQL statements. They can differ in licensing, supported capabilities, administrative workflows, data types, functions, and exact syntax. Learning relational concepts and standard SQL provides a useful foundation, but always check the documentation for the particular RDBMS.

Common Beginner Confusions

“MySQL and SQL are the same.”

They are different. MySQL is database server software; SQL is the language used to communicate with relational database systems.

“Every database uses exactly the same SQL.”

Relational products share many SQL foundations, but commands, functions, data types, and administrative features can vary by product.

“MySQL only works on Linux or with PHP.”

MySQL runs on multiple operating systems and can be used by programs written in many programming languages. LAMP is one common combination, not a restriction.

“A GUI removes the need to learn SQL.”

Graphical tools simplify some tasks, but SQL remains central to querying and managing relational data.

“WordPress is MySQL.”

WordPress is an application. It can use MySQL as a backend for storing application data, but the application and the database server are separate software components.

Where to Learn Next