Chapter Two
Chapter Two
Chapter Two
1
facility that the clients can run on the same computer as the server or on another computer
(communication via a local network or the Internet).
Allows roll-back: MySQL allows transactions to be rolled back, commit and crash recovery.
High Performance: MySQL is faster, more reliable and cheaper because of its unique
storage engine architecture.
High Flexibility: MySQL supports a large number of embedded applications which makes
MySQL very flexible.
High Productivity: MySQL uses Triggers, Stored procedures and views which allows the
developer to give a higher productivity.
2
MEDIUMINT A medium-sized integer that can be signed or unsigned. If signed, the allowable
range is from -8388608 to 8388607. If unsigned, the allowable range is from 0
to 16777215. You can specify a width of up to 9 digits.
BIGINT A large integer that can be signed or unsigned. If signed, the allowable range is
from -9223372036854775808 to 9223372036854775807. If unsigned, the
allowable range is from 0 to 18446744073709551615. You can specify a width
of up to 20 digits.
FLOAT(m,d) A floating-point number that cannot be unsigned. You can define the display
length (m) and the number of decimals (d). This is not required and will default
to 10,2, where 2 is the number of decimals and 10 is the total number of digits
(including decimals). Decimal precision can go to 24 places for a float.
DOUBLE(m,d) A double precision floating-point number that cannot be unsigned. You can
define the display length (m) and the number of decimals (d). This is not required
and will default to 16,4, where 4 is the number of decimals. Decimal precision
can go to 53 places for a double. Real is a synonym for double.
DECIMAL(m,d) An unpacked floating-point number that cannot be unsigned. In unpacked
decimals, each decimal corresponds to one byte. Defining the display length (m)
and the number of decimals (d) is required. Numeric is a synonym for decimal.
Date and Time Data Type
Data Type Maximum Size Explanation
DATE Values range from '1000-01-01' to '9999-12-31'. Displayed as 'yyyy-mm-dd'.
DATETIME Values range from '1000-01-01 00:00:00' to Displayed as 'yyyy-mm-dd
'9999-12-31 23:59:59'. hh:mm:ss'.
TIMESTAMP(m) Values range from '1970-01-01 00:00:01' UTC to Displayed as 'YYYY-MM-
'2038-01-19 03:14:07' TC. DD HH:MM:SS'.
TIME Values range from '-838:59:59' to '838:59:59'. Displayed as 'HH:MM:SS'.
YEAR[(2|4)] Year value as 2 digits or 4 digits. Default is 4 digits.
String Data Types
Data Type Maximum Size Explanation
3
CHAR(size) Maximum size of 255 Where size is the number of characters to store.
characters. Fixed-length strings. Space padded on right to
equal size characters.
VARCHAR(size) Maximum size of 255 Where size is the number of characters to store.
characters. Variable-length string.
TINYTEXT(size) Maximum size of 255 Where size is the number of characters to store.
characters.
TEXT(size) Maximum size of Where size is the number of characters to store.
65,535 characters.
MEDIUMTEXT(size) Maximum size of Where size is the number of characters to store.
16,777,215 characters.
LONGTEXT(size) Maximum size of 4GB Where size is the number of characters to store.
or 4,294,967,295
characters.
BINARY(size) Maximum size of 255 Where size is the number of binary characters to
characters. store. Fixed-length strings. Space padded on
right to equal size characters. (introduced in
MySQL 4.1.2)
VARBINARY(size) Maximum size of 255 Where size is the number of characters to store.
characters. Variable-length string. (introduced in MySQL
4.1.2)
Large Object Data Types (LOB) Data Types
Data Type Syntax Maximum Size
TINYBLOB Maximum size of 255 bytes.
BLOB(size) Maximum size of 65,535 bytes.
MEDIUMBLOB Maximum size of 16,777,215 bytes.
LONGTEXT Maximum size of 4gb or 4,294,967,295 characters.
4
2.4.1. Hardware and Software Tools Requirement
This section describes the minimum and recommended system requirements for a successful
MySQL installation. This section describes the minimum hardware requirements for the MySQL.
2 CPU Cores
2 GB RAM
Disk I/O subsystem applicable to a write-intensive database
This section describes the recommended hardware requirements for MySQL.
4 CPU Cores or more
8 GB RAM or more
RAID10 or RAID 0+1 disk setup
MySQL Enterprise Monitor Disk Space Requirements
The following table lists the minimum disk space required to install MySQL Enterprise Service
Manager and MySQL Enterprise Monitor Agent on each platform.
Table 3.1 Required Disk Space
Platform Service Manager Minimum Disk Space Agent Minimum Disk Space
Linux x86
32-bit N/A 600 MB
Linux x86
64-bit 1.3 GB 800 MB
Mac OS X 1.2 GB 700 MB
Solaris x86
64-bit 1.8 GB 800 MB
Solaris Sparc
64-bit 1.7 GB 600 MB
300 MB (the FreeBSD installation
does not include a JRE. It is assumed
a compatible JRE is present on the
Free BSD N/A system.)
Windows x86
32-bit N/A 500 MB
Windows x86
64-bit 800 MB 500 MB
Download MySQL community Server - GPL edition 8.0.13.0 from this link and start installation.
https://dev.mysql.com/downloads/file/?id=480824
5
License Agreement: Click on I accept the license term and press next.
6
Choose a Setup Type
Developer Default Setup Type: Installs the MySQL Server and the tools required for MySQL
application development. This is useful if you intend to develop applications for an existing
server. This Setup Type includes:
o MySQL Server
o MySQL Shell: The new MySQL client application to manage MySQL Servers and InnoDB
cluster instances.
o MySQL Router: High availability router daemon for InnoDB cluster setups to be installed
on application nodes.
o MySQL Workbench: The GUI application to develop for and manage the server.
o MySQL for Excel: Excel plug-in to easily access and manipulate MySQL data.
o MySQL for Visual Studio: To work with the MySQL Server from VS.
o MySQL Connectors: Connector/Net, Java, C/C++, OBDC and others.
o Examples and tutorials: To help you get started with your development.
o Documentation: Allows you to read the documentation offline.
Server Only Setup Type: Installs only the MySQL Server. This type should be used where
you want to deploy a MySQL Server, but will not be developing MySQL applications.
Client Only Setup Type: Installs the tools required for MySQL application development, but
does not include the MySQL Server itself. This is useful if you intend to develop applications
for an existing server. This Setup Type includes:
o MySQL Shell: The new MySQL client application to manage MySQL Servers and
InnoDB cluster instances.
o MySQL Router: High availability router daemon for InnoDB cluster setups to be installed
on application nodes.
o MySQL Workbench: The GUI application to develop for and manage the server.
o MySQL Visual Studio Plugin: To work with the MySQL Server from VS.
o MySQL Connectors: Connector/Net, Java, C/C++, OBDC and others.
o Examples and tutorials: To help you get started with your development.
o Documentation: Allows you to read the documentation offline.
7
Full Setup Type: Installs all of the products available in this catalog including MySQL Server,
MySQL Shell, MySQL Router, MySQL Workbench, MySQL Connectors, documentation,
samples and examples and much more.
Custom Setup Type: Allows you to select exactly which products you would like to install.
This also allows to pick other server versions and architectures (depending on your OS).
Select developer default setup type and then click next.
If you have installed the same product may occur path conflict. You can use the same path or
you can change it to a new one.
8
Press yes and then click next.
9
MySQL Check Requirements
If you have not installed visual studio and python the popup window will display, then click on
yes and then click on next button.
10
Installation: Press execute to install the product.
11
MySQL Server 8.0.12.0 Product Configuration
Group Replication: Select the Default Standalone MySQL Server/Classic MySQL Server
Replication.
12
Type and Networking
Authentication Method
13
Account and Roles: Create account and don’t forget the password.
Also, you can add another user may be DB admin or DB manager, DB designer backup admin
etc. To add additional user, click on add user.
14
Root user account and another ADMIN DB admin user account.
15
Apply for Configuration
16
Click finish button.
MySQL Server 8.0.12.0 Product Configuration is completed.
17
MySQL Router 8.0.12.0 Product Configuration
18
Click on next to configure the MySQL Router
19
Click on next,
Connect to Server
20
Click next
Apply Configuration
Click on execute.
21
Click on finish.
Click on next.
Installation Complete
Click on finish.
22
Installation completed so next open MySQL workbench or MySQL command line client or
MySQL command line client - Unicode.
Summery
MySQL is used for many small and big businesses. It is written in C and C++. MySQL is a fast,
easy to use relational database. It is currently the most popular open-source database. It is very
commonly used in conjunction with PHP scripts to create powerful and dynamic server-side
applications. MySQL is secure, scalable, compatible on many operating systems, easy to use, fast,
high performance, high available, flexible, free to download and productive RDBMS. MySQL
support several SQL data types and it has its own built-in data types. MySQL version less than
5.0 doesn't support ROLE, COMMIT and stored procedure. Also, it does not support a very large
database size as efficiently. Installation and configuration of MySQL 8.0.12.0 community edition
that contains MySQL server, MySQL workbench and other products have been discussed.
Review Questions
1. What is MySQL?
2. What is the advantage and disadvantage of MySQL?
3. What are the most commonly used data types in MySQL?
4. Which data type is appropriate to store large objects in MySQL?
5. List and describe MySQL fixed size and dynamic data types?
6. Why is MySQL compatible with different operating systems?
7. Describe the purpose of m and d of DOUBLE(m,d) MySQL data type?
8. Can we store image, audio, and video data in MySQL database? If you say yes, how and
where?
9. What is the default width of integer data type?
10. Which data type is display 'yyyy-mm-dd hh:mm:ss'?
11. What is the maximum size of long text?
23