SlideShare a Scribd company logo
A Brief Introduction to MySQL
By Nishkam,
Neeraj,Saurabh,
Hrishikesh and
Somesh
Pointers
 What is MySQL ? Its good features.
 Installation guide.
 Security and Privilege System
 Compatibility with standards
 Locks – an interesting feature
 Table types
 Some more salient features
 Replication
What Is MySQL?
 A fast, reliable, easy-to-use, multi-user multi-
threaded relational database system.
 It is freely available and released under GPL
(GNU General Public License ).
Why Use MySQL ?
 MySQL server can handle very large
databases.
 Offers rich and very useful set of functions.
 Connectivity, speed and security make MySQL
very suited for accessing database on a
network.
 A lot of contributed software available.
What Does MySQL Offer ?
 A privilege and password system that is very
flexible and secure and allows host-based
verification.
 Multi-threaded request-handling using kernel
thread.
 Replication features.
 Very actively developed.
 Memory leak proof.
Quick Installation Guide
• tar –zxvf Mysql.x.xx.xx.tar.gz
 cd Mysql-x.xx.xx.xx
 ./configure –prefix=/usr/local/mysql
 make
 make install
 scripts/mysql_install_db
 safe_mysqld
 Mysql –u root password ‘mypassword’
Configuring MySql
 --bindir=Dir specifies dir for binaries
 --localstatedir=Dir data dir
 --with-tcp-port=portno
 --with-unix-sock-path=absolute-path
 --with-mysqld-ldflag=-all-static
 --with-charset=charset (default Latin1)
 --with-low-memory
Support
 Works on many different platforms like
FreeBSD , NetBSD , Linux 2.0+, Windows ’95,
’98, 2000 & NT, HP-UX etc
 There are client tools and APIs available in c,
c++, java, perl, python, php, Tcl
Security in mysql
 Issues that bother: eavesdropping,altering
 Uses ACL’s (Access Control Lists) , also
there’s some support for SSL connections
 Has inbuilt methods for storing confidential
data like passwords in encrypted form.
 Access is restricted thru grant of privileges to
users,hosts
Privileges provided by mysql
 The five tables:
user,db,host,tables_priv,columns_priv
 The privileges come into play only if there is a
retrieval of data from the database, or updation
of data in the database,e.g:
select 1+1; calculator 
 File privilege : load data infile, select …. Into
outfile
How the privilege system works
 First reference to user followed by db and host , takes
place during connection verification
 Reference to tables_priv and columns_priv at data
access stage
 Ordering of user table on the basis of more specific
host values first, followed by more specific user values.
 For security purposes , mysql disallows host
addresses of the form :192.168.7.yahoo.com
Some tips on security
 Beneficial to invest in a firewall ; check using “telnet
server_port 3306”
 Do not rely on the data entered by the user, he can
trick the code by using special character sequences
 Make use of tcpdump, to check the whether or not
mysql data streams r unencrypted:
tcpdump –l –i eth0 –w – src port 3306|strings
 Dont run mysqld as root.
 Don’t give process and file privileges to users as far as
possible.
Continued…..
 Following mysqld options affect security:
1. –- secure 2. – skip-grant-privileges
3. – skip-name-resolve 4. –skip-networking
 Passwords by default are stored in hashed form in
database.But if the scrambled password is known the
hacker can still log in as the user.
 Passwords can be stored in my.cnf file when
non-interactive access has to be done
 Inbuilt functions for hashing: password,
encrypt,encode,decode
Compatibility with Standards
What doesn’t MySQL have ?
 Transactions – no provision for commit and
rollback
 No nested sub-queries
 Views are not supported
 Foreign keys not used for referential integrity
checks
Compatibility (contd.)
What extra does MySQL have ?
 Locking/Unlocking of tables
 Atomicity of operations
 Directory organization
 Access of tables across tables
 Several other features, discussed later…
More about Locks !
 Locks help in maintaining integrity, atomicity
 Read locks – enable you to only read from the
locked tables.
 Write locks – enable you to read and write
exclusively. Other threads can’t access/update
currently locked tables
 Write locks have higher priority than read locks
MySql Table Types
 Creates a .frm file that holds the table and column definition.
 Syntax for defining table type is .. :
CREATE TABLE test ( )
TYPE=HEAP ..
 Categorization of types : Transaction safe type and Non
transaction safe type.
 Transaction Safe table types allow rollbacks,restore changes if
update fails ,etc .
 Non Transaction Safe table types are much faster ,use less
disk space as well as memory for updates.
MyISAM tables
 Use B-Tree indexing to store the keys, string indexes
are compressed .
 MyISAM itself supports three different table formats: a)
static (fixed length) b) Dynamic c) Compressed
 Static : fastest ,secure and simplest format ,
used when there are no varchar, blob or text.
 Dynamic : each record stores a header that contain its
length
 Compressed : created using myisampack tool , they
are read only ,use very little space as each record is
compressed separately
 ISAM is a deprecated version of MyISAM
Merge tables
 A collection of identical MyISAM tables which are used
collectively.
 FOR eg :
CREATE TABLE t1 (a INT AUTO_INCREMENT
PRIMARY KEY, message CHAR(20));
CREATE TABLE t2 (a INT AUTO_INCREMENT
PRIMARY KEY, message CHAR(20)) ;
CREATE TABLE total (a INT NOT NULL, message
CHAR(20), KEY(a)) TYPE=MERGE UNION=(t1,t2)
• allowed : select ,insert and Operations update .
Heap tables and Berkley DB
 Use hashed index and are stored in memory
 Generally used for temporary tables .
•Berkley DB is used for making the tables
transaction safe
MySQL Language Reference
OPTIMIZE
 Syntax :: … OPTIMIZE TABLE tbl_name[,tbl_name]..
 Used only for MyISAM tables
 It performs the following functions :repairs the table if the table has
deleted rows,sorts the index,and the statistics are also made to
date.
CHECK
 Syntax :: … CHECK
TABLE tbl_name[,tbl_name...] [TYPE = [QUICK | FAST | EXTEND
| CHANGED]]
MySQL Language Reference
 Checks a table for errors and updates the key
statistics of the table
BACKUP
 BACKUP TABLE tbl_name[,tbl_name...] TO
'/path/to/backup/directory‘
 This again works only for MyISAM
ANALYZE
 During analysis the table is locked with a read
lock
MySQL Language Reference
REPAIR
 Syntax:
REPAIR TABLE tbl_name[,tbl_name...] [TYPE = QUICK]
FLUSH
 Syntax :
FLUSH flush_option [,flush_option]
 Used to clear the internal cache of Mysql
 It has various options like HOSTS,LOGS,PRIVELEDGES,
TABLES tbl_names,etc
Replication in MySQL
 What??
 One server is designated as the master, while the other
( or others) as slave(s)
 Updates done only on master and binary logs made
 The slave connects to the master, catches up on the
missed updates, and then starts receiving updates
immediately as they come to the master.
 Why??
 For robustness you have two systems and switch to
the backup if you have problems with the master.
 The extra speed is achieved by sending a part of the
non-updating queries to the replica server.
How To (SLAVE)
• Upgrade both slave and master to 3.23.15 or higher.
• PUT THESE IN my.cnf of SLAVE
• master-host,user,passwd
• server-id=< unique no>= 1 & <=2^32-1
• master-connect-retry !! (keep trying)
• master-info-file
• replicate-rewrite-db
• skip-slave-start
• Restart the slave(s)
How To (SLAVE) (contd)
• Take a snapshot of all the tables/databases on
the master
• Use command LOAD TABLE <tblname>
FROM MASTER (3.23.23)+
 SLAVE START/STOP
 FLUSH SLAVE
HOW TO (MASTER)
 log-bin , FLUSH MASTER , FLUSH SLAVE
 When you start the slave thread will be created
 Tables are not Locked
 SET SQL_LOG_BIN=0/1
 CHANGE MASTER TO master_def_list

More Related Content

What's hot

Linux System Administration Crash Course
Linux System Administration Crash CourseLinux System Administration Crash Course
Linux System Administration Crash Course
Jason Cannon
 
MySQL DBA OCP 1Z0-883
MySQL DBA OCP 1Z0-883MySQL DBA OCP 1Z0-883
MySQL DBA OCP 1Z0-883
Kwaye Kant
 
Introduction Mysql
Introduction Mysql Introduction Mysql
Introduction Mysql
Gerben Menschaert
 
MySQL DBA
MySQL DBAMySQL DBA
MySQL DBA
lalit choudhary
 
Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems
Ahmed El-Arabawy
 
Mysql all
Mysql allMysql all
File System Resource Mangement
File System Resource MangementFile System Resource Mangement
File System Resource Mangement
Raphael Ejike
 
Mysql grand
Mysql grandMysql grand
Mysql grand
Siddique Ibrahim
 
MySQL Architecture and Engine
MySQL Architecture and EngineMySQL Architecture and Engine
MySQL Architecture and EngineAbdul Manaf
 
Getting started into mySQL
Getting started into mySQLGetting started into mySQL
Getting started into mySQL
Siddique Ibrahim
 
Getting started with my sql
Getting started with my sqlGetting started with my sql
Getting started with my sql
Web Sky
 
Scalable Web Solutions - Use Case: Regulatory Reform In Vietnam On eZ Publish...
Scalable Web Solutions - Use Case: Regulatory Reform In Vietnam On eZ Publish...Scalable Web Solutions - Use Case: Regulatory Reform In Vietnam On eZ Publish...
Scalable Web Solutions - Use Case: Regulatory Reform In Vietnam On eZ Publish...Ivo Lukač
 
My S Q L Introduction for 1 day training
My S Q L  Introduction for 1 day trainingMy S Q L  Introduction for 1 day training
My S Q L Introduction for 1 day trainingIvan Tu
 
Active Directory
Active DirectoryActive Directory
Active Directory
Hameda Hurmat
 

What's hot (17)

Linux System Administration Crash Course
Linux System Administration Crash CourseLinux System Administration Crash Course
Linux System Administration Crash Course
 
MySQL DBA OCP 1Z0-883
MySQL DBA OCP 1Z0-883MySQL DBA OCP 1Z0-883
MySQL DBA OCP 1Z0-883
 
Introduction Mysql
Introduction Mysql Introduction Mysql
Introduction Mysql
 
MySQL DBA
MySQL DBAMySQL DBA
MySQL DBA
 
Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems
 
Mysql all
Mysql allMysql all
Mysql all
 
Slides
SlidesSlides
Slides
 
File System Resource Mangement
File System Resource MangementFile System Resource Mangement
File System Resource Mangement
 
Mysql ppt
Mysql pptMysql ppt
Mysql ppt
 
Mysql grand
Mysql grandMysql grand
Mysql grand
 
MySQL Architecture and Engine
MySQL Architecture and EngineMySQL Architecture and Engine
MySQL Architecture and Engine
 
Redis
RedisRedis
Redis
 
Getting started into mySQL
Getting started into mySQLGetting started into mySQL
Getting started into mySQL
 
Getting started with my sql
Getting started with my sqlGetting started with my sql
Getting started with my sql
 
Scalable Web Solutions - Use Case: Regulatory Reform In Vietnam On eZ Publish...
Scalable Web Solutions - Use Case: Regulatory Reform In Vietnam On eZ Publish...Scalable Web Solutions - Use Case: Regulatory Reform In Vietnam On eZ Publish...
Scalable Web Solutions - Use Case: Regulatory Reform In Vietnam On eZ Publish...
 
My S Q L Introduction for 1 day training
My S Q L  Introduction for 1 day trainingMy S Q L  Introduction for 1 day training
My S Q L Introduction for 1 day training
 
Active Directory
Active DirectoryActive Directory
Active Directory
 

Similar to MySQL 简要介绍

Learn my sql at amc square learning
Learn my sql at amc square learningLearn my sql at amc square learning
Learn my sql at amc square learning
ASIT Education
 
MySQL Reference Manual
MySQL Reference ManualMySQL Reference Manual
MySQL Reference Manualwebhostingguy
 
My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)
Gustavo Rene Antunez
 
Collaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsCollaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAs
Nelson Calero
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
Pankaj Sipl
 
Mysql-Basics.pptx
Mysql-Basics.pptxMysql-Basics.pptx
Mysql-Basics.pptx
ssuserf5adce
 
Securing your database servers from external attacks
Securing your database servers from external attacksSecuring your database servers from external attacks
Securing your database servers from external attacks
Alkin Tezuysal
 
My sql basic
My sql basicMy sql basic
My sql basic
Prabhat gangwar
 
Performence tuning
Performence tuningPerformence tuning
Performence tuning
Vasudeva Rao
 
Mysql 2007 Tech At Digg V3
Mysql 2007 Tech At Digg V3Mysql 2007 Tech At Digg V3
Mysql 2007 Tech At Digg V3epee
 
MySQL Server Backup, Restoration, And Disaster Recovery Planning Presentation
MySQL Server Backup, Restoration, And Disaster Recovery Planning PresentationMySQL Server Backup, Restoration, And Disaster Recovery Planning Presentation
MySQL Server Backup, Restoration, And Disaster Recovery Planning PresentationColin Charles
 
Privilege Escalation with Metasploit
Privilege Escalation with MetasploitPrivilege Escalation with Metasploit
Privilege Escalation with Metasploit
egypt
 
Ms Tech Ed Best Practices For Exchange Server Cluster Deployments June 2003
Ms Tech Ed   Best Practices For Exchange Server Cluster Deployments June 2003Ms Tech Ed   Best Practices For Exchange Server Cluster Deployments June 2003
Ms Tech Ed Best Practices For Exchange Server Cluster Deployments June 2003
Armando Leon
 
MySQL HA with PaceMaker
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMaker
Kris Buytaert
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdl
sqlhjalp
 
How to Manage Scale-Out Environments with MariaDB MaxScale
How to Manage Scale-Out Environments with MariaDB MaxScaleHow to Manage Scale-Out Environments with MariaDB MaxScale
How to Manage Scale-Out Environments with MariaDB MaxScale
MariaDB plc
 

Similar to MySQL 简要介绍 (20)

Mysql2
Mysql2Mysql2
Mysql2
 
Learn my sql at amc square learning
Learn my sql at amc square learningLearn my sql at amc square learning
Learn my sql at amc square learning
 
Fudcon talk.ppt
Fudcon talk.pptFudcon talk.ppt
Fudcon talk.ppt
 
MySQL Reference Manual
MySQL Reference ManualMySQL Reference Manual
MySQL Reference Manual
 
My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)
 
Sql material
Sql materialSql material
Sql material
 
Collaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsCollaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAs
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
Mysql-Basics.pptx
Mysql-Basics.pptxMysql-Basics.pptx
Mysql-Basics.pptx
 
Mysql tutorial 5257
Mysql tutorial 5257Mysql tutorial 5257
Mysql tutorial 5257
 
Securing your database servers from external attacks
Securing your database servers from external attacksSecuring your database servers from external attacks
Securing your database servers from external attacks
 
My sql basic
My sql basicMy sql basic
My sql basic
 
Performence tuning
Performence tuningPerformence tuning
Performence tuning
 
Mysql 2007 Tech At Digg V3
Mysql 2007 Tech At Digg V3Mysql 2007 Tech At Digg V3
Mysql 2007 Tech At Digg V3
 
MySQL Server Backup, Restoration, And Disaster Recovery Planning Presentation
MySQL Server Backup, Restoration, And Disaster Recovery Planning PresentationMySQL Server Backup, Restoration, And Disaster Recovery Planning Presentation
MySQL Server Backup, Restoration, And Disaster Recovery Planning Presentation
 
Privilege Escalation with Metasploit
Privilege Escalation with MetasploitPrivilege Escalation with Metasploit
Privilege Escalation with Metasploit
 
Ms Tech Ed Best Practices For Exchange Server Cluster Deployments June 2003
Ms Tech Ed   Best Practices For Exchange Server Cluster Deployments June 2003Ms Tech Ed   Best Practices For Exchange Server Cluster Deployments June 2003
Ms Tech Ed Best Practices For Exchange Server Cluster Deployments June 2003
 
MySQL HA with PaceMaker
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMaker
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdl
 
How to Manage Scale-Out Environments with MariaDB MaxScale
How to Manage Scale-Out Environments with MariaDB MaxScaleHow to Manage Scale-Out Environments with MariaDB MaxScale
How to Manage Scale-Out Environments with MariaDB MaxScale
 

More from YUCHENG HU

Confluencewiki 使用空间
Confluencewiki 使用空间Confluencewiki 使用空间
Confluencewiki 使用空间
YUCHENG HU
 
Git
GitGit
Presta shop 1.6 如何安装简体中文语言文件
Presta shop 1.6 如何安装简体中文语言文件Presta shop 1.6 如何安装简体中文语言文件
Presta shop 1.6 如何安装简体中文语言文件
YUCHENG HU
 
Logback 介绍
Logback 介绍Logback 介绍
Logback 介绍
YUCHENG HU
 
Presta shop 1.6 详细安装指南
Presta shop 1.6 详细安装指南Presta shop 1.6 详细安装指南
Presta shop 1.6 详细安装指南
YUCHENG HU
 
Presta shop 1.6 的安装环境
Presta shop 1.6 的安装环境Presta shop 1.6 的安装环境
Presta shop 1.6 的安装环境
YUCHENG HU
 
Presta shop 1.6 如何安装简体中文语言文件
Presta shop 1.6 如何安装简体中文语言文件Presta shop 1.6 如何安装简体中文语言文件
Presta shop 1.6 如何安装简体中文语言文件
YUCHENG HU
 
Presta shop 1.6 图文安装教程
Presta shop 1.6 图文安装教程Presta shop 1.6 图文安装教程
Presta shop 1.6 图文安装教程
YUCHENG HU
 
V tiger 5.4.0 图文安装教程
V tiger 5.4.0 图文安装教程V tiger 5.4.0 图文安装教程
V tiger 5.4.0 图文安装教程
YUCHENG HU
 
Confluence 回顾(retrospectives) 蓝图 cwikiossez
Confluence 回顾(retrospectives) 蓝图   cwikiossezConfluence 回顾(retrospectives) 蓝图   cwikiossez
Confluence 回顾(retrospectives) 蓝图 cwikiossezYUCHENG HU
 
Confluence 会议记录(meeting notes)蓝图 cwikiossez
Confluence 会议记录(meeting notes)蓝图   cwikiossezConfluence 会议记录(meeting notes)蓝图   cwikiossez
Confluence 会议记录(meeting notes)蓝图 cwikiossez
YUCHENG HU
 
VTIGER - 销售机会 - CWIKIOSSEZ
VTIGER - 销售机会 - CWIKIOSSEZ VTIGER - 销售机会 - CWIKIOSSEZ
VTIGER - 销售机会 - CWIKIOSSEZ
YUCHENG HU
 
Confluence 使用一个模板新建一个页面 cwikiossez
Confluence 使用一个模板新建一个页面     cwikiossezConfluence 使用一个模板新建一个页面     cwikiossez
Confluence 使用一个模板新建一个页面 cwikiossez
YUCHENG HU
 
Confluence 使用模板
Confluence 使用模板Confluence 使用模板
Confluence 使用模板
YUCHENG HU
 
Cwikiossez confluence 订阅页面更新邮件通知
Cwikiossez confluence 订阅页面更新邮件通知Cwikiossez confluence 订阅页面更新邮件通知
Cwikiossez confluence 订阅页面更新邮件通知
YUCHENG HU
 
Cwikiossez confluence 关注页面 博客页面和空间
Cwikiossez confluence 关注页面 博客页面和空间Cwikiossez confluence 关注页面 博客页面和空间
Cwikiossez confluence 关注页面 博客页面和空间
YUCHENG HU
 
My sql università di enna a.a. 2005-06
My sql   università di enna a.a. 2005-06My sql   università di enna a.a. 2005-06
My sql università di enna a.a. 2005-06
YUCHENG HU
 
My sql would you like transactions
My sql would you like transactionsMy sql would you like transactions
My sql would you like transactions
YUCHENG HU
 
MySQL 指南
MySQL 指南MySQL 指南
MySQL 指南
YUCHENG HU
 
MySQL 简要介绍
MySQL 简要介绍MySQL 简要介绍
MySQL 简要介绍
YUCHENG HU
 

More from YUCHENG HU (20)

Confluencewiki 使用空间
Confluencewiki 使用空间Confluencewiki 使用空间
Confluencewiki 使用空间
 
Git
GitGit
Git
 
Presta shop 1.6 如何安装简体中文语言文件
Presta shop 1.6 如何安装简体中文语言文件Presta shop 1.6 如何安装简体中文语言文件
Presta shop 1.6 如何安装简体中文语言文件
 
Logback 介绍
Logback 介绍Logback 介绍
Logback 介绍
 
Presta shop 1.6 详细安装指南
Presta shop 1.6 详细安装指南Presta shop 1.6 详细安装指南
Presta shop 1.6 详细安装指南
 
Presta shop 1.6 的安装环境
Presta shop 1.6 的安装环境Presta shop 1.6 的安装环境
Presta shop 1.6 的安装环境
 
Presta shop 1.6 如何安装简体中文语言文件
Presta shop 1.6 如何安装简体中文语言文件Presta shop 1.6 如何安装简体中文语言文件
Presta shop 1.6 如何安装简体中文语言文件
 
Presta shop 1.6 图文安装教程
Presta shop 1.6 图文安装教程Presta shop 1.6 图文安装教程
Presta shop 1.6 图文安装教程
 
V tiger 5.4.0 图文安装教程
V tiger 5.4.0 图文安装教程V tiger 5.4.0 图文安装教程
V tiger 5.4.0 图文安装教程
 
Confluence 回顾(retrospectives) 蓝图 cwikiossez
Confluence 回顾(retrospectives) 蓝图   cwikiossezConfluence 回顾(retrospectives) 蓝图   cwikiossez
Confluence 回顾(retrospectives) 蓝图 cwikiossez
 
Confluence 会议记录(meeting notes)蓝图 cwikiossez
Confluence 会议记录(meeting notes)蓝图   cwikiossezConfluence 会议记录(meeting notes)蓝图   cwikiossez
Confluence 会议记录(meeting notes)蓝图 cwikiossez
 
VTIGER - 销售机会 - CWIKIOSSEZ
VTIGER - 销售机会 - CWIKIOSSEZ VTIGER - 销售机会 - CWIKIOSSEZ
VTIGER - 销售机会 - CWIKIOSSEZ
 
Confluence 使用一个模板新建一个页面 cwikiossez
Confluence 使用一个模板新建一个页面     cwikiossezConfluence 使用一个模板新建一个页面     cwikiossez
Confluence 使用一个模板新建一个页面 cwikiossez
 
Confluence 使用模板
Confluence 使用模板Confluence 使用模板
Confluence 使用模板
 
Cwikiossez confluence 订阅页面更新邮件通知
Cwikiossez confluence 订阅页面更新邮件通知Cwikiossez confluence 订阅页面更新邮件通知
Cwikiossez confluence 订阅页面更新邮件通知
 
Cwikiossez confluence 关注页面 博客页面和空间
Cwikiossez confluence 关注页面 博客页面和空间Cwikiossez confluence 关注页面 博客页面和空间
Cwikiossez confluence 关注页面 博客页面和空间
 
My sql università di enna a.a. 2005-06
My sql   università di enna a.a. 2005-06My sql   università di enna a.a. 2005-06
My sql università di enna a.a. 2005-06
 
My sql would you like transactions
My sql would you like transactionsMy sql would you like transactions
My sql would you like transactions
 
MySQL 指南
MySQL 指南MySQL 指南
MySQL 指南
 
MySQL 简要介绍
MySQL 简要介绍MySQL 简要介绍
MySQL 简要介绍
 

Recently uploaded

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 

Recently uploaded (20)

State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 

MySQL 简要介绍

  • 1. A Brief Introduction to MySQL By Nishkam, Neeraj,Saurabh, Hrishikesh and Somesh
  • 2. Pointers  What is MySQL ? Its good features.  Installation guide.  Security and Privilege System  Compatibility with standards  Locks – an interesting feature  Table types  Some more salient features  Replication
  • 3. What Is MySQL?  A fast, reliable, easy-to-use, multi-user multi- threaded relational database system.  It is freely available and released under GPL (GNU General Public License ).
  • 4. Why Use MySQL ?  MySQL server can handle very large databases.  Offers rich and very useful set of functions.  Connectivity, speed and security make MySQL very suited for accessing database on a network.  A lot of contributed software available.
  • 5. What Does MySQL Offer ?  A privilege and password system that is very flexible and secure and allows host-based verification.  Multi-threaded request-handling using kernel thread.  Replication features.  Very actively developed.  Memory leak proof.
  • 6. Quick Installation Guide • tar –zxvf Mysql.x.xx.xx.tar.gz  cd Mysql-x.xx.xx.xx  ./configure –prefix=/usr/local/mysql  make  make install  scripts/mysql_install_db  safe_mysqld  Mysql –u root password ‘mypassword’
  • 7. Configuring MySql  --bindir=Dir specifies dir for binaries  --localstatedir=Dir data dir  --with-tcp-port=portno  --with-unix-sock-path=absolute-path  --with-mysqld-ldflag=-all-static  --with-charset=charset (default Latin1)  --with-low-memory
  • 8. Support  Works on many different platforms like FreeBSD , NetBSD , Linux 2.0+, Windows ’95, ’98, 2000 & NT, HP-UX etc  There are client tools and APIs available in c, c++, java, perl, python, php, Tcl
  • 9. Security in mysql  Issues that bother: eavesdropping,altering  Uses ACL’s (Access Control Lists) , also there’s some support for SSL connections  Has inbuilt methods for storing confidential data like passwords in encrypted form.  Access is restricted thru grant of privileges to users,hosts
  • 10. Privileges provided by mysql  The five tables: user,db,host,tables_priv,columns_priv  The privileges come into play only if there is a retrieval of data from the database, or updation of data in the database,e.g: select 1+1; calculator   File privilege : load data infile, select …. Into outfile
  • 11. How the privilege system works  First reference to user followed by db and host , takes place during connection verification  Reference to tables_priv and columns_priv at data access stage  Ordering of user table on the basis of more specific host values first, followed by more specific user values.  For security purposes , mysql disallows host addresses of the form :192.168.7.yahoo.com
  • 12. Some tips on security  Beneficial to invest in a firewall ; check using “telnet server_port 3306”  Do not rely on the data entered by the user, he can trick the code by using special character sequences  Make use of tcpdump, to check the whether or not mysql data streams r unencrypted: tcpdump –l –i eth0 –w – src port 3306|strings  Dont run mysqld as root.  Don’t give process and file privileges to users as far as possible.
  • 13. Continued…..  Following mysqld options affect security: 1. –- secure 2. – skip-grant-privileges 3. – skip-name-resolve 4. –skip-networking  Passwords by default are stored in hashed form in database.But if the scrambled password is known the hacker can still log in as the user.  Passwords can be stored in my.cnf file when non-interactive access has to be done  Inbuilt functions for hashing: password, encrypt,encode,decode
  • 14. Compatibility with Standards What doesn’t MySQL have ?  Transactions – no provision for commit and rollback  No nested sub-queries  Views are not supported  Foreign keys not used for referential integrity checks
  • 15. Compatibility (contd.) What extra does MySQL have ?  Locking/Unlocking of tables  Atomicity of operations  Directory organization  Access of tables across tables  Several other features, discussed later…
  • 16. More about Locks !  Locks help in maintaining integrity, atomicity  Read locks – enable you to only read from the locked tables.  Write locks – enable you to read and write exclusively. Other threads can’t access/update currently locked tables  Write locks have higher priority than read locks
  • 17. MySql Table Types  Creates a .frm file that holds the table and column definition.  Syntax for defining table type is .. : CREATE TABLE test ( ) TYPE=HEAP ..  Categorization of types : Transaction safe type and Non transaction safe type.  Transaction Safe table types allow rollbacks,restore changes if update fails ,etc .  Non Transaction Safe table types are much faster ,use less disk space as well as memory for updates.
  • 18. MyISAM tables  Use B-Tree indexing to store the keys, string indexes are compressed .  MyISAM itself supports three different table formats: a) static (fixed length) b) Dynamic c) Compressed  Static : fastest ,secure and simplest format , used when there are no varchar, blob or text.  Dynamic : each record stores a header that contain its length  Compressed : created using myisampack tool , they are read only ,use very little space as each record is compressed separately  ISAM is a deprecated version of MyISAM
  • 19. Merge tables  A collection of identical MyISAM tables which are used collectively.  FOR eg : CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20)); CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20)) ; CREATE TABLE total (a INT NOT NULL, message CHAR(20), KEY(a)) TYPE=MERGE UNION=(t1,t2) • allowed : select ,insert and Operations update .
  • 20. Heap tables and Berkley DB  Use hashed index and are stored in memory  Generally used for temporary tables . •Berkley DB is used for making the tables transaction safe
  • 21. MySQL Language Reference OPTIMIZE  Syntax :: … OPTIMIZE TABLE tbl_name[,tbl_name]..  Used only for MyISAM tables  It performs the following functions :repairs the table if the table has deleted rows,sorts the index,and the statistics are also made to date. CHECK  Syntax :: … CHECK TABLE tbl_name[,tbl_name...] [TYPE = [QUICK | FAST | EXTEND | CHANGED]]
  • 22. MySQL Language Reference  Checks a table for errors and updates the key statistics of the table BACKUP  BACKUP TABLE tbl_name[,tbl_name...] TO '/path/to/backup/directory‘  This again works only for MyISAM ANALYZE  During analysis the table is locked with a read lock
  • 23. MySQL Language Reference REPAIR  Syntax: REPAIR TABLE tbl_name[,tbl_name...] [TYPE = QUICK] FLUSH  Syntax : FLUSH flush_option [,flush_option]  Used to clear the internal cache of Mysql  It has various options like HOSTS,LOGS,PRIVELEDGES, TABLES tbl_names,etc
  • 24. Replication in MySQL  What??  One server is designated as the master, while the other ( or others) as slave(s)  Updates done only on master and binary logs made  The slave connects to the master, catches up on the missed updates, and then starts receiving updates immediately as they come to the master.  Why??  For robustness you have two systems and switch to the backup if you have problems with the master.  The extra speed is achieved by sending a part of the non-updating queries to the replica server.
  • 25. How To (SLAVE) • Upgrade both slave and master to 3.23.15 or higher. • PUT THESE IN my.cnf of SLAVE • master-host,user,passwd • server-id=< unique no>= 1 & <=2^32-1 • master-connect-retry !! (keep trying) • master-info-file • replicate-rewrite-db • skip-slave-start • Restart the slave(s)
  • 26. How To (SLAVE) (contd) • Take a snapshot of all the tables/databases on the master • Use command LOAD TABLE <tblname> FROM MASTER (3.23.23)+  SLAVE START/STOP  FLUSH SLAVE
  • 27. HOW TO (MASTER)  log-bin , FLUSH MASTER , FLUSH SLAVE  When you start the slave thread will be created  Tables are not Locked  SET SQL_LOG_BIN=0/1  CHANGE MASTER TO master_def_list