- MySQL Basics
- MySQL - Home
- MySQL - Introduction
- MySQL - Features
- MySQL - Versions
- MySQL - Variables
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Node.js Syntax
- MySQL - Java Syntax
- MySQL - Python Syntax
- MySQL - Connection
- MySQL - Workbench
- MySQL Databases
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Show Database
- MySQL - Copy Database
- MySQL - Database Export
- MySQL - Database Import
- MySQL - Database Info
- MySQL Users
- MySQL - Create Users
- MySQL - Drop Users
- MySQL - Show Users
- MySQL - Change Password
- MySQL - Grant Privileges
- MySQL - Show Privileges
- MySQL - Revoke Privileges
- MySQL - Lock User Account
- MySQL - Unlock User Account
- MySQL Tables
- MySQL - Create Tables
- MySQL - Show Tables
- MySQL - Alter Tables
- MySQL - Rename Tables
- MySQL - Clone Tables
- MySQL - Truncate Tables
- MySQL - Temporary Tables
- MySQL - Repair Tables
- MySQL - Describe Tables
- MySQL - Add/Delete Columns
- MySQL - Show Columns
- MySQL - Rename Columns
- MySQL - Table Locking
- MySQL - Drop Tables
- MySQL - Derived Tables
- MySQL Queries
- MySQL - Queries
- MySQL - Constraints
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Replace Query
- MySQL - Insert Ignore
- MySQL - Insert on Duplicate Key Update
- MySQL - Insert Into Select
- MySQL Indexes
- MySQL - Indexes
- MySQL - Create Index
- MySQL - Drop Index
- MySQL - Show Indexes
- MySQL - Unique Index
- MySQL - Clustered Index
- MySQL - Non-Clustered Index
- MySQL Operators and Clauses
- MySQL - Where Clause
- MySQL - Limit Clause
- MySQL - Distinct Clause
- MySQL - Order By Clause
- MySQL - Group By Clause
- MySQL - Having Clause
- MySQL - AND Operator
- MySQL - OR Operator
- MySQL - Like Operator
- MySQL - IN Operator
- MySQL - ANY Operator
- MySQL - EXISTS Operator
- MySQL - NOT Operator
- MySQL - NOT EQUAL Operator
- MySQL - IS NULL Operator
- MySQL - IS NOT NULL Operator
- MySQL - Between Operator
- MySQL - UNION Operator
- MySQL - UNION vs UNION ALL
- MySQL - MINUS Operator
- MySQL - INTERSECT Operator
- MySQL - INTERVAL Operator
- MySQL Joins
- MySQL - Using Joins
- MySQL - Inner Join
- MySQL - Left Join
- MySQL - Right Join
- MySQL - Cross Join
- MySQL - Full Join
- MySQL - Self Join
- MySQL - Delete Join
- MySQL - Update Join
- MySQL - Union vs Join
- MySQL Keys
- MySQL - Unique Key
- MySQL - Primary Key
- MySQL - Foreign Key
- MySQL - Composite Key
- MySQL - Alternate Key
- MySQL Triggers
- MySQL - Triggers
- MySQL - Create Trigger
- MySQL - Show Trigger
- MySQL - Drop Trigger
- MySQL - Before Insert Trigger
- MySQL - After Insert Trigger
- MySQL - Before Update Trigger
- MySQL - After Update Trigger
- MySQL - Before Delete Trigger
- MySQL - After Delete Trigger
- MySQL Data Types
- MySQL - Data Types
- MySQL - VARCHAR
- MySQL - BOOLEAN
- MySQL - ENUM
- MySQL - DECIMAL
- MySQL - INT
- MySQL - FLOAT
- MySQL - BIT
- MySQL - TINYINT
- MySQL - BLOB
- MySQL - SET
- MySQL Regular Expressions
- MySQL - Regular Expressions
- MySQL - RLIKE Operator
- MySQL - NOT LIKE Operator
- MySQL - NOT REGEXP Operator
- MySQL - regexp_instr() Function
- MySQL - regexp_like() Function
- MySQL - regexp_replace() Function
- MySQL - regexp_substr() Function
- MySQL Fulltext Search
- MySQL - Fulltext Search
- MySQL - Natural Language Fulltext Search
- MySQL - Boolean Fulltext Search
- MySQL - Query Expansion Fulltext Search
- MySQL - ngram Fulltext Parser
- MySQL Functions & Operators
- MySQL - Date and Time Functions
- MySQL - Arithmetic Operators
- MySQL - Numeric Functions
- MySQL - String Functions
- MySQL - Aggregate Functions
- MySQL Misc Concepts
- MySQL - NULL Values
- MySQL - Transactions
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - SubQuery
- MySQL - Comments
- MySQL - Check Constraints
- MySQL - Storage Engines
- MySQL - Export Table into CSV File
- MySQL - Import CSV File into Database
- MySQL - UUID
- MySQL - Common Table Expressions
- MySQL - On Delete Cascade
- MySQL - Upsert
- MySQL - Horizontal Partitioning
- MySQL - Vertical Partitioning
- MySQL - Cursor
- MySQL - Stored Functions
- MySQL - Signal
- MySQL - Resignal
- MySQL - Character Set
- MySQL - Collation
- MySQL - Wildcards
- MySQL - Alias
- MySQL - ROLLUP
- MySQL - Today Date
- MySQL - Literals
- MySQL - Stored Procedure
- MySQL - Explain
- MySQL - JSON
- MySQL - Standard Deviation
- MySQL - Find Duplicate Records
- MySQL - Delete Duplicate Records
- MySQL - Select Random Records
- MySQL - Show Processlist
- MySQL - Change Column Type
- MySQL - Reset Auto-Increment
- MySQL - Coalesce() Function
MySQL Tutorial
MySQL Tutorial
MySQL is the most popular and a free Open Source Relational Database Management System (RDBMS). An RDBMS system stores the data in the form of tables that might be related to each other. MySQL uses Structured Query Language (SQL) to store, manage and retrieve data, and control the accessibility to the data. It is one of the best RDBMS being used for developing web-based software applications.
MySQL is written in C and C++. Its SQL parser is written in yacc, but it uses a home-brewed lexical analyzer.
MySQL works on many system platforms, such as, Linux, macOS, Microsoft Windows, AIX, BSDi, FreeBSD, HP-UX, ArcaOS, eComStation, IBM i, IRIX, NetBSD, Novell NetWare, OpenBSD, OpenSolaris, OS/2 Warp, QNX, Oracle Solaris, Symbian, SunOS, SCO OpenServer, SCO UnixWare, Sanos and Tru64.
This tutorial will give you quick start with MySQL and make you comfortable with MySQL programming.
MySQL Examples
Consider an example table CUSTOMERS created in the MySQL database. This table contains the details of customers like ID, NAME, AGE, ADDRESS, SALARY.
ID | NAME | AGE | ADDRESS | SALARY |
---|---|---|---|---|
1 | Ramesh | 32 | Ahmedabad | 2000.00 |
2 | Khilan | 25 | Delhi | 1500.00 |
3 | Kaushik | 23 | Kota | 2000.00 |
4 | Chaitali | 25 | Mumbai | 6500.00 |
5 | Hardik | 27 | Bhopal | 8500.00 |
6 | Komal | 22 | Hyderabad | 4500.00 |
7 | Muffy | 24 | Indore | 10000.00 |
Since MySQL uses SQL to manage data, it also uses almost all DDL, DML and DCL statements. For instance, the following DML statement lists the records of all customers who are 25 years old.
SELECT * FROM CUSTOMERS WHERE AGE = 25;
Following records are displayed as a result-set −
ID | NAME | AGE | ADDRESS | SALARY |
---|---|---|---|---|
2 | Khilan | 25 | Delhi | 1500.00 |
4 | Chaitali | 25 | Mumbai | 6500.00 |
MySQL Online Editor
In this tutorial, we provide a MySQL Online Editor which helps you to Edit and Execute the MySQL code directly from your browser. Click on the icon to run the following MySQL code to be executed on the CUSTOMERS table and retrieve the records matching with the given condition.
SELECT * FROM CUSTOMERS WHERE NAME = 'Chaitali';
This Online Editor will save you the time to install the MySQL setup in order to execute any query. Try our MySQL Online Editor now.
Why to Learn MySQL?
MySQL is generally faster, more secure and efficient than other relational databases. Some of world's fastest growing organizations make use of MySQL to efficiently power their high-volume web sites, business-critical systems and packaged software.
However, whether you choose MySQL for your application or not, totally depends on your organization's resources and aim. Usually, MySQL is used by smaller businesses that do not have large data sets, because of its cost efficiency and simple setup.
MySQL Jobs and Opportunities
MySQL professionals are in high demand as more and more organizations are using this open-source database system for efficient data management. If you have the skills, you could earn an average salary of around $150,000 per year, but it can vary depending on your location, experience, and job role.
Here are some of the top companies actively looking for MySQL experts for roles like Database Administrator, Database Developer, Database Tester, Data Scientist, ETL Developer, Database Migration Expert, Cloud Database Expert, and more. They need people who can manage and optimize their databases, build data-driven applications, and extract insights from large datasets −
- Amazon
- Netflix
- Infosys
- Tata Consultancy Services (TCS)
- Tech Mahindra
- Wipro
- Uber
- Wipro
- Trello
- And many more...
To get started, you can use our user-friendly tutorials, which are designed to help you learn MySQL and prepare for technical interviews or certification exams. You can learn at your own pace, anytime and anywhere.
With the right MySQL skills and knowledge, you can kickstart a rewarding career in the ever-expanding field of data management and analytics. You could be the part of the professionals who are driving innovation and data-driven decision-making in some of the world's most renowned companies.
Who Should Learn MySQL
This MySQL tutorial has been prepared for beginners to help them understand the basics to advanced concepts related to MySQL database.
Prerequisites to Learn MySQL
Before you start doing practice with various types of examples given in this reference, I'm making an assumption that you are already aware about what is database, especially RDBMS and what is a computer programming language.
Frequently Asked Questions about MySQL
Following are very Frequently Asked Questions(FAQ) about MySQL, and this section tries to answer them briefly.
MySQL is a popular open-source relational database management system (RDBMS). It organizes data into tables with rows and columns. Users can interact with MySQL using SQL (Structured Query Language) to perform operations like inserting, updating, and querying data. The system works by processing SQL commands to manage and retrieve data efficiently.
MySQL was developed by Swedish company MySQL AB, founded by David Axmark, Allan Larsson, and Michael "Monty" Widenius. It was later bought by Sun Microsystems in 2008, which was subsequently acquired by Oracle Corporation in 2010.
You can install MySQL from the MySQL Installer Community, along with other MySQL products you require. The MySQL Installer will allow you to install a certain version of MySQL or you can customize the installation as per your requirements. For more detailed information on how to install MySQL, click here.
Since MySQL uses SQL to store and manage the data, the data types used in MySQL are also the same as data types in SQL. Following are three categories of SQL data types.
- String Data types.
- Numeric Data types.
- Date and time Data types.
Here are the summarized list of tips which you can follow to start learning MySQL.
- Install MySQL database on your computer system.
- Follow our tutorial step by step from the very beginning.
- Read more articles, watch online courses or buy a book on MySQL to enhance your knowledge.
- Try to develop a small software using PHP or Python which makes use of the MySQL database.
The time it takes to learn MySQL varies, but basic proficiency can be gained in a few weeks with consistent practice. Mastering more advanced features may take a few months of dedicated learning and hands-on experience. Regular practice and real-world application contribute to the speed of learning MySQL.
The latest version of MySQL was 8.0. Upgrading to the latest version is recommended for security and feature enhancements.
To check the MySQL version in Linux, you can use the following command in the terminal:
- mysql --version
This command will display the MySQL client version. If you want to check the server version, you can use:
- mysql -u your_username -p -e "SELECT version();"
Replace "your_username" with your MySQL username, and you will be prompted to enter your password. After entering the password, the command will display the MySQL server version.
To access your MySQL database, you can use the MySQL command-line client or a graphical user interface (GUI) tool. Here are the basic steps for both:
Using MySQL Command-Line Client
- Open terminal/command prompt.
- Enter: mysql -u your_username -p.
- Enter your password when prompted.
Using GUI Tool (e.g., MySQL Workbench)
- Download and install the tool.
- Create a new connection with your details.
- Test the connection.
- Use the GUI to manage your MySQL database.
MySQL is a popular open-source relational database management system (RDBMS) known for its ease of use and scalability. Its main features include support for SQL queries, efficient data storage and retrieval, and robust transaction management, making it suitable for a wide range of applications, from small websites to large enterprise systems. Additionally, MySQL offers strong security measures and a vibrant community for support and development.
To start, stop, or restart the MySQL server, you can use the command-line interface. The exact commands may vary depending on your operating system. Here are instructions for different operating systems:
Windows:
- To Start MySQL Server: Open a command prompt with administrator privileges and run the following command: net start mysql.
- To Stop MySQL Server: Open a command prompt with administrator privileges and run the following command: net stop mysql.
- To Restart MySQL Server: You can stop and start the MySQL service using the commands mentioned above. Alternatively, you can use the MySQL Notifier or the Services application to restart the MySQL service.
Linux (Ubuntu/Debian):
- To Start MySQL Server: sudo service mysql start.
- To Stop MySQL Server: sudo service mysql stop.
- To Restart MySQL Server: sudo service mysql restart.
macOS:
- To Start MySQL Server: sudo brew services start mysql.
- To Stop MySQL Server: sudo brew services stop mysql.
- To Restart MySQL Server: sudo brew services restart mysql.
These are general commands, and depending on your specific setup, you might need to adjust them. Also, note that on Linux, the service management commands may vary depending on the distribution (e.g., Ubuntu, CentOS).
Remember to replace "mysql" with the actual service name if it's different in your system.
A MySQL schema can simply be defined as a blueprint of the database. It stores all the information of the tables, its attributes and entities. As MySQL is a relational database management system, it is important to have schema as it also represents the relationship between the attributes and entities of multiple tables.
As a beginner, you can use our simple and the best MySQL tutorial to learn MySQL. We have removed all the unnecessary complexity while teaching you these MySQL concepts. You can start learning it now: Learn MySQL.