0% found this document useful (0 votes)
12 views10 pages

MySQL Introduction

MySQL is a widely-used open-source relational database management system (RDBMS) that utilizes Structured Query Language (SQL) for data management and retrieval. It is known for its speed, security, and efficiency, making it suitable for both small and large businesses. The tutorial covers MySQL's features, basic concepts, and practical examples, including user creation and database management commands.

Uploaded by

Diksha Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views10 pages

MySQL Introduction

MySQL is a widely-used open-source relational database management system (RDBMS) that utilizes Structured Query Language (SQL) for data management and retrieval. It is known for its speed, security, and efficiency, making it suitable for both small and large businesses. The tutorial covers MySQL's features, basic concepts, and practical examples, including user creation and database management commands.

Uploaded by

Diksha Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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.
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
Ahmedab
1 Ramesh 32 2000.00
ad
2 Khilan 25 Delhi 1500.00
3 Kaushik 23 Kota 2000.00
4 Chaitali 25 Mumbai 6500.00
5 Hardik 27 Bhopal 8500.00
Hyderaba
6 Komal 22 4500.00
d
10000.0
7 Muffy 24 Indore
0
Since MySQL uses SQL to manage data, it also uses
almost all DDL (Data Definition Language): CREATE,
ALTER, DROP, TRUNCATE, RENAME , DML (Data
Manipulation Language): SELECT, INSERT, UPDATE,
DELETE , DCL (Data Control Language): GRANT,
REVOKE 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 −
ADDRE SALAR
ID NAME AGE
SS Y
1500.0
2 Khilan 25 Delhi
0
6500.0
4 Chaitali 25 Mumbai
0
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.

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.

What is a Database?
A database is used to store a collection of data (which
can either be structured or unstructured).
Each database has one or more distinct APIs for
creating, accessing, managing, searching and
replicating the data it holds.
Other kinds of data storages can also be used to
manage data, such as files on the file system or large
hash tables in memory, but data fetching and writing
would not be so fast and easy with those type of
systems.
Nowadays, we use relational database management
systems (RDBMS) to store and manage huge volume of
data.
In such a database, the data is stored in a structured
way with the help of different tables.
Relations are established among these tables using
primary keys or other keys known as Foreign Keys.
A Relational DataBase Management System
(RDBMS) is a software that −
 Enables you to implement a database with tables,
columns and indexes.
 Guarantees the Referential Integrity between rows
of various tables.
 Updates the indexes automatically.
 Interprets an SQL query and combines information
from various tables.
RDBMS Terminology
Before we proceed to explain the MySQL database
system, let us revise a few definitions related to the
database.
 Database − A database is a collection of tables,
with related data.
 Table − A table is a matrix with data. A table in a
database looks like a simple spreadsheet.
 Column − One column (data element) contains
data of one and the same kind, for example the
column postcode.
 Row − A row (= tuple, entry or record) is a group
of related data, for example the data of one
subscription.
 Redundancy − Storing data twice, redundantly to
make the system faster.
 Primary Key − A primary key is unique. A key
value can not occur twice in one table. With a key,
you can only find one row.
 Foreign Key − A foreign key is the linking pin
between two tables.
 Compound Key − A compound key (composite
key) is a key that consists of multiple columns,
because one column is not sufficiently unique.
 Index − An index in a database resembles an
index at the back of a book.
 Referential Integrity − Referential Integrity
makes sure that a foreign key value always points
to an existing row.

MySQL Database
MySQL is a fast, easy-to-use RDBMS being used for
many small and big businesses. It is developed,
marketed and supported by MySQL AB, which is a
Swedish company. MySQL is becoming so popular
because of many good reasons −
 MySQL is released under an open-source license.
So you have nothing to pay to use it.
 MySQL is a very powerful program in its own right.
It handles a large subset of the functionality of the
most expensive and powerful database packages.
 MySQL uses a standard form of the well-known SQL
data language.
 MySQL works on many operating systems and with
many languages including PHP, PERL, C, C++,
JAVA, etc.
 MySQL works very quickly and works well even
with large data sets.
 MySQL is very friendly to PHP, the most
appreciated language for web development.
 MySQL supports large databases, up to 50 million
rows or more in a table. The default file size limit
for a table is 4GB, but you can increase this (if your
operating system can handle it) to a theoretical
limit of 8 million terabytes (TB).
 MySQL is customizable. The open-source GPL
license allows programmers to modify the MySQL
software to fit their own specific environments.
History of MySQL
 Development of MySQL by Michael Widenius &
David Axmark beginning in 1994.
 First internal release on 23rd May 1995.
 Windows Version was released on the 8th January
1998 for Windows 95 and NT.
 Version 3.23: beta from June 2000, production
release January 2001.
 Version 4.0: beta from August 2002, production
release March 2003 (unions).
 Version 4.1: beta from June 2004, production
release October 2004.
 Version 5.0: beta from March 2005, production
release October 2005.
 Sun Microsystems acquired MySQL AB on the 26th
February 2008.
 Version 5.1: production release 27th November
2008.
 Oracle acquired Sun Microsystems on 27th January
2010.
 Version 5.5: general availability on 3rd December
2010
 Version 5.6: general availability on 5th February
2013
 Version 5.7: general availability on 21st October
2015
 Version 8.0: general availability on 19th April 2018
 MySQL is a type of relational database that stores and manages
the data based on Structured Query Language (SQL) queries.
Thus, making it a structured database, i.e., the data stored in this
relational databases is in the form of tables.
 It is a fast, easy-to-use RDBMS being used for many small and
big businesses, it is developed, marketed and supported by a
Swedish Company called MySQL AB.
 Features of MySQL
 One of the major reasons MySQL is considered one of the most
popular relational databases is because of its abundant features.
Let us look at them one by one −
 Open-Source
 MySQL is open-source, which means this software can be
downloaded, used and modified by anyone. It is free-to-use and
easy-to-understand. The source code of MySQL can be studied,
and changed based on the requirements. It uses GPL, i.e. GNU
General Public license which defines rules and regulations
regarding what can and can't be done using the application.
 Quick and Reliable
 MySQL stores data efficiently in the memory ensuring that data
is consistent, and not redundant. Hence, data access and
manipulation using MySQL is quick. It is considered one of the
fastest relational databases with higher productivity as well.
 High Performance
 MySQL provides comparatively higher performance without
affecting its functionality. It also has a very little memory
leakage making it memory efficient as well.
 Scalable
 Scalability refers to the ability of systems to work easily with
small amounts of data, large amounts of data, clusters of
machines, and so on. MySQL server was developed to work
with large databases.
 Data Types
 It contains multiple data types such as unsigned integers, signed
integers, float (FLOAT), double (DOUBLE), character (CHAR),
variable character (VARCHAR), text, blob, date, time, datetime,
timestamp, year, and so on.
 Character Sets
 It supports different character sets, and this includes latin1
(cp1252 character encoding), German, Ujis, other Unicode
character sets and so on.
 Secure
 It provides a secure interface since it has a password system
which is flexible, and ensures that it is verified based on the host
before accessing the database. The password is encrypted while
connecting to the server.
 Support for large databases
 It comes with support for large databases, which could contain
about 40 to 50 million records, 150,000 to 200,000 tables and up
to 5,000,000,000 rows.
 Platform Independent
 MySQL can be run on various operating systems including
Windows, Linux, macOS etc. in several programming languages
like C, C++, Java, Python, Perl, PHP etc.
 Client and Utility Programs
 MySQL server also comes with many client and utility
programs. This includes Command line programs such as
'mysqladmin' and graphical programs such as 'MySQL
Workbench'. MySQL client programs are written in a variety of
languages. Client library (code encapsulated in a module) can be
written in C or C++ and would be available for clients that have
C bindings.

Creating Mysql user:


CREATE USER 'user1'@'localhost' IDENTIFIED WITH
caching_sha2_password BY 'PassWord@12';
Grant :
GRANT ALL ON *.* TO 'user1'@'localhost';
Check User list:
SELECT user, host FROM [Link];
Remove user:
DROP USER 'user1'@'localhost';

CREATE DATABASE user1db;


SHOW DATABASES;

You might also like