What Is MySQL? Install, Connect and Run Your First Queries

MySQL 50 min min read Updated: Nov 27, 2026 Beginner
What Is MySQL? Install, Connect and Run Your First Queries
Beginner Topic 1 of 3

What Is MySQL?

MySQL is one of the most popular open-source relational database servers. It stores data in tables, understands SQL, and powers a huge part of the web (WordPress, many online shops, and countless apps). It is owned by Oracle, and a community fork called MariaDB exists with similar commands.

FactDetail
TypeRelational database management system (RDBMS)
Default engineInnoDB (transactions, foreign keys, row locks)
LanguageSQL, plus MySQL extras
Typical useWeb applications, shops, content systems, reporting
Versions in this courseMySQL 8.0 (the examples were run on 8.0.46)

Client and Server

MySQL works in two parts. The server (mysqld) stores data and runs queries. A client connects to it over the network or a local socket and sends SQL. Examples of clients: the mysql command line program, MySQL Workbench, DBeaver, and your application code.

text Your app or mysql client --- SQL ---> MySQL server (mysqld) ---> data files on disk <--- rows ----

Installing MySQL

Choose the option that suits you. These commands are shown for reference and were not run in this lesson, because the practice server here was already installed.

SystemHow
Ubuntu or Debiansudo apt install mysql-server, then sudo mysql to log in as administrator
Windows or macOSDownload the MySQL Installer or the DMG from the official MySQL site, or use brew install mysql on macOS
Dockerdocker run --name mysql -e MYSQL_ROOT_PASSWORD=secret -p 3306:3306 -d mysql:8.0
CloudManaged MySQL from AWS RDS, Google Cloud SQL or Azure Database for MySQL
Secure the root account After installing, set a strong root password and do not use root for applications. The security lesson later shows how to create limited users.

Connecting with the mysql Client

bash mysql -u root -p # ask for the password mysql -h 127.0.0.1 -P 3306 -u shop_user -p shop # remote host, port, user, database

Inside the client, end every statement with ;. Type exit or press Ctrl+D to leave.

Your First Queries

SELECT can run without any table. Check the server version and the current database:

sql SELECT 'Hello, MySQL!' AS greeting, 2 + 3 AS sum_result;

Result:

greetingsum_result
Hello, MySQL!5
sql SELECT VERSION() AS version, DATABASE() AS current_database;

The version differs on your machine. Our test server runs MySQL 8.0.46.

Useful SHOW Commands

CommandShows
SHOW DATABASES;All databases on the server
USE shop;Selects the database to work in
SHOW TABLES;Tables in the current database
DESCRIBE customers;Columns, types and keys of a table (also DESC)
SHOW CREATE TABLE customers;The exact CREATE TABLE statement
SHOW VARIABLES LIKE 'version%';Server settings
SHOW STATUS LIKE 'Threads%';Live server counters

Now create the practice shop database from the first lesson of this course. Here is a look at a table in it:

sql SHOW TABLES;

Result:

Tables_in_shop
customers
order_items
orders
products
sql DESCRIBE customers;

Result:

FieldTypeNullKeyDefaultExtra
idintNOPRINULL(empty)
namevarchar(100)NO(empty)NULL(empty)
cityvarchar(50)YES(empty)NULL(empty)
emailvarchar(100)YESUNINULL(empty)
joineddateNO(empty)NULL(empty)

The sql_mode Setting

sql_mode tells MySQL how strict to be. MySQL 8 enables strict modes by default, so bad data is rejected instead of silently changed.

sql SELECT @@sql_mode AS sql_mode;

Result:

sql_mode
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
ModeEffect
STRICT_TRANS_TABLESReject invalid values (too long text, wrong type) with an error
ONLY_FULL_GROUP_BYReject GROUP BY queries that select non-grouped columns
NO_ZERO_DATEReject '0000-00-00' dates
ERROR_FOR_DIVISION_BY_ZEROError on division by zero in data changes
Do not turn strict mode off to make an error disappear The error is telling you that your data or query is wrong. Fix the data. Very old tutorials show MySQL silently cutting text, which hides bugs.
sql INSERT INTO customers (id, name, joined) VALUES (7, 'Gita', 'not-a-date');
Error

ERROR 1292: Incorrect date value: 'not-a-date' for column 'joined' at row 1

Comments and Case Rules

sql -- single line comment # also a single line comment in MySQL /* a block comment */
  • Keywords are not case sensitive: select and SELECT are the same.
  • Table and database names are case sensitive on Linux, and not on Windows. Always use lowercase names to stay safe.
  • Strings use single quotes: 'London'. Names with spaces or reserved words use backticks: order .

Common Beginner Mistakes

MistakeWhat happensFix
Forgetting the semicolonThe client waits for more inputEnd every statement with ;
Running queries without USE databaseError: No database selectedRun USE shop; or prefix shop.customers
Using root in applicationsA bug or attack can destroy everythingCreate a limited user
Mixed-case table namesWorks on Windows, fails on LinuxUse lowercase with underscores
Turning off strict modeBad data enters silentlyKeep strict mode on

Practice

  1. Run SELECT VERSION(); on your server.
  2. List your databases and tables.
  3. Describe the products table and name its primary key.
  4. Insert a row with an invalid date and read the error.

Conclusion

MySQL is a client-server relational database. Connect with the mysql client, use SHOW and DESCRIBE to explore, remember that MySQL 8 is strict by default, and keep names lowercase.

Quick Summary: What MySQL is, install, connect, SHOW commands, sql_mode, first queries.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators