SlideShare une entreprise Scribd logo
1  sur  27
MySQL Tutorial MySQL Architecture Common Tools Examples  António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Overview What is MySQL? António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 ,[object Object],[object Object],[object Object],[object Object],wits
MySQL Overview What does it do? António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],wits
MySQL Architecture Three layer model: António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 ,[object Object],[object Object],[object Object],wits
MySQL Architecture Some internal components: António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 Each client connection gets its own thread within the server process.  When clients (applications) connect to the MySQL server, the server needs to authenticate them. Before even parsing the query, though, the server consults the query cache, which only stores SELECT statements, along with their result sets. The  storage engine does affect how the server optimizes query.
MySQL Architecture Transactional  properties (ACID): António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 MySQL Innodb storage engine fully supports transactions, a transaction can be viewed as a block of instructions that act are applied coherently to the database, in turn this means ACID standard compliance: Atomicity :  Each transaction block is treated as a single instruction, all of the block must succeed or none. Consistency :  Only valid data is written to the database, and the resulting state is valid. Isolation :  While performing operations in a transaction block, other transactions don't see our changes. Durability :  If the transaction returns a successful state it is persisted to the database.
MySQL Architecture Storage engines: António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 MySQL supports several storage engines that act as handlers for different table types. MySQL storage engines include both those that handle transaction-safe tables and those that handle non-transaction-safe tables.
MySQL Installation António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 Windows Installation wizard:   http://dev.mysql.com/downloads/mysql/5.1.html#win32 Linux: Debian Based: apt-get install mysql-server-5.0 RPM based: rpm -ivh MySQL-server-*5.1.31-0.rhel3.i386.rpm YUM Based: yum install mysql-sever Gentoo Based: emerge mysql Macintosh:  http://dev.mysql.com/downloads/mysql/5.1.html#macosx All in One Packages MAMP – Macintosh Apache MySQL and PHP http://www.mamp.info/en/index.php WAMP – Windows Apache MySQL and PHP http://www.wampserver.com/en/
MySQL Overview MySQL Files: António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 wits In Linux the configuration file is typically located at /etc/mysql/my.cnf, but may vary for the different Linux flavours, this also applies to the database files them selves which are located in the /var/lib/MySQL. Regardless of the storage engine, every MySQL table you create is represented, on disk, by a .frm file, which describes the table’s format (i.e. the table definition). The file bears the same name as the table, with a .frm extension. The .frm format is the same on all platforms but in the description of the .frm format that follows, the examples come from tables created under the Linux operating system. /var/lib/mysql/db.frm   #Table definition /var/lib/mysql/db.MYD   #MyISAM data file /var/lib/mysql/db.MYI   #MyISAM Index file /var/lib/mysql/ibdata1   #Innodb data file
MySQL Command Line tools António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 On Linux the a user can interact with MySQL using the command line, in this interaction a user can create, update, delete and modify a MySQL database using the following command line tools mysql: general database and table interaction: mysql -u username -ppassword -h localhost db_name mysqldump: database backup  mysqldump db_name > outputfile  mysqlbinlog: binary log processing  mysqlbinlog  logfile_1 logfile_2 ... logfile_n > out.sql mysqlbinlog logfile_1 logfile_2 ... logfile_n | mysql  mysql_install_db: database restore  mysql_install_db
MySQL Graphical tools MySQL administrator António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 ,[object Object],[object Object],[object Object],[object Object],[object Object]
MySQL Graphical tools MySQL query browser António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 MySQL query browser is a simple query tool used to interact with a MySQl database.
MySQL Graphical tools phpmyadim António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 Phpmyadmin is a browser tool developed in php, that allows you to manage a mysql database.
MySQL and Gaia António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 DbBenchmark is a simple java application that makes use of GaiaTools (currently outdated), and performs a series of standard tests.  Class mapping: mdb.properties test control: dbbenchmark.properties.mysql_elem gaia.cu1.tools.db.username=username gaia.cu1.tools.db.password=password gaia.cu1.tools.db.driver=com.mysql.jdbc.Driver gaia.cu1.tools.db.url=jdbc:mysql://localhost:3306/gaia_test?rewriteBatchedStatements=true Running the tests: ant mysql_elem_random DbBenchmark
MySQL and Gaia António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 MDBIngestorExtractor is a application that allows the extraction and ingestion “gbin” files, which are  Class mapping: conf/mdb.properties MDB Extractor Ingestor properties: conf/ingestor.properties conf/extractor.properties gaia.cu1.tools.db.username=username gaia.cu1.tools.db.password=password gaia.cu1.tools.db.url=jdbc:mysql://localhost:3306/test gaia.cu1.tools.db.driver=com.mysql.jdbc.Driver Lauching the extactor/ingestor: bash ingest.sh  bash extract.sh   MDBIngestorExtractor
MySQL queries António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09 Create a database: create database database_name; Display databases: show databases; Selecting a database use database_name Display  tables: show tables Create a table: create table create table person  (id int, person varchar (32) )  engine=engine_name Deleting a table: Drop table table_name Insert a value in a table: Insert into table_name.db_name  (field1 , field 2...) Values (v1, v2, ...), (v1',v2'); View data all data in a table: select * from table name where cond = value Select data from  two different tables: Select field1, field2 from tbl1, tbl2 where field3= field4; Sow create table statement: show create table tbl_name  Show database variables: show variables;
Q&A ,[object Object],[object Object],[object Object],[object Object],António Amorim, Carlos Jesus. CU1 - First Database Testing Meeting, 20/Nov/08
MySQL Graphical tools phpmysqladmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Graphical tools phpmysqladmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Graphical tools Phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09
MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 -  DBWorkshop  9-10 /Feb/09

Contenu connexe

Tendances

MySQL Replication Basics
MySQL Replication BasicsMySQL Replication Basics
MySQL Replication BasicsAbdul Manaf
 
MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)Mydbops
 
MySQL Features & Implementation
MySQL Features & ImplementationMySQL Features & Implementation
MySQL Features & ImplementationOSSCube
 
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 DBAsNelson Calero
 
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
 
Advantage & Disadvantage of MySQL
Advantage & Disadvantage of MySQLAdvantage & Disadvantage of MySQL
Advantage & Disadvantage of MySQLKentAnderson43
 
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyMySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyContinuent
 
MySQL :What's New #GIDS16
MySQL :What's New #GIDS16MySQL :What's New #GIDS16
MySQL :What's New #GIDS16Sanjay Manwani
 

Tendances (13)

MySQL database
MySQL databaseMySQL database
MySQL database
 
MySQL Replication Basics
MySQL Replication BasicsMySQL Replication Basics
MySQL Replication Basics
 
Database storage engines
Database storage enginesDatabase storage engines
Database storage engines
 
MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)
 
MySQL Features & Implementation
MySQL Features & ImplementationMySQL Features & Implementation
MySQL Features & Implementation
 
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
 
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
 
Introduction Mysql
Introduction Mysql Introduction Mysql
Introduction Mysql
 
Advantage & Disadvantage of MySQL
Advantage & Disadvantage of MySQLAdvantage & Disadvantage of MySQL
Advantage & Disadvantage of MySQL
 
My sql
My sqlMy sql
My sql
 
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware companyMySQL High Availability and Disaster Recovery with Continuent, a VMware company
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
 
MySQL :What's New #GIDS16
MySQL :What's New #GIDS16MySQL :What's New #GIDS16
MySQL :What's New #GIDS16
 
MySQL ppt
MySQL ppt MySQL ppt
MySQL ppt
 

Similaire à Slides

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
 
SULTHAN's PHP, MySQL & wordpress
SULTHAN's PHP, MySQL & wordpressSULTHAN's PHP, MySQL & wordpress
SULTHAN's PHP, MySQL & wordpressSULTHAN BASHA
 
Tutorial MySQL com Java
Tutorial MySQL com JavaTutorial MySQL com Java
Tutorial MySQL com JavaMySQL Brasil
 
Mysql
MysqlMysql
MysqlSHC
 
Compare the capabilities of the Microsoft Access, Microsoft SQL Serv.pdf
Compare the capabilities of the Microsoft Access, Microsoft SQL Serv.pdfCompare the capabilities of the Microsoft Access, Microsoft SQL Serv.pdf
Compare the capabilities of the Microsoft Access, Microsoft SQL Serv.pdfarihantplastictanksh
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlsqlhjalp
 
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15Dave Stokes
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterKenny Gryp
 
Case study on mysql in rdbms
Case study on mysql in rdbmsCase study on mysql in rdbms
Case study on mysql in rdbmsRajalakshmiK19
 
Getting started with my sql
Getting started with my sqlGetting started with my sql
Getting started with my sqlWeb Sky
 

Similaire à Slides (20)

My sql basic
My sql basicMy sql basic
My sql basic
 
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)
 
SULTHAN's PHP, MySQL & wordpress
SULTHAN's PHP, MySQL & wordpressSULTHAN's PHP, MySQL & wordpress
SULTHAN's PHP, MySQL & wordpress
 
Mysql ppt
Mysql pptMysql ppt
Mysql ppt
 
Introduction to Mysql
Introduction to MysqlIntroduction to Mysql
Introduction to Mysql
 
Sql installation
Sql installationSql installation
Sql installation
 
Lovely
LovelyLovely
Lovely
 
Mysql
MysqlMysql
Mysql
 
Tutorial MySQL com Java
Tutorial MySQL com JavaTutorial MySQL com Java
Tutorial MySQL com Java
 
Mysql
MysqlMysql
Mysql
 
Compare the capabilities of the Microsoft Access, Microsoft SQL Serv.pdf
Compare the capabilities of the Microsoft Access, Microsoft SQL Serv.pdfCompare the capabilities of the Microsoft Access, Microsoft SQL Serv.pdf
Compare the capabilities of the Microsoft Access, Microsoft SQL Serv.pdf
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdl
 
Mysql tutorial 5257
Mysql tutorial 5257Mysql tutorial 5257
Mysql tutorial 5257
 
MySQL on Docker and Kubernetes
MySQL on Docker and KubernetesMySQL on Docker and Kubernetes
MySQL on Docker and Kubernetes
 
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
MySQL for Oracle DBA -- Rocky Mountain Oracle User Group Training Days '15
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
 
Case study on mysql in rdbms
Case study on mysql in rdbmsCase study on mysql in rdbms
Case study on mysql in rdbms
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
MySQL-adv.ppt
MySQL-adv.pptMySQL-adv.ppt
MySQL-adv.ppt
 
Getting started with my sql
Getting started with my sqlGetting started with my sql
Getting started with my sql
 

Plus de webhostingguy

Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Frameworkwebhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guidewebhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serverswebhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidationwebhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreementwebhostingguy
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructurewebhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.pptwebhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandiserswebhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Productswebhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mbwebhostingguy
 

Plus de webhostingguy (20)

File Upload
File UploadFile Upload
File Upload
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
 
Notes8
Notes8Notes8
Notes8
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
 

Slides

  • 1. MySQL Tutorial MySQL Architecture Common Tools Examples António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 2.
  • 3.
  • 4.
  • 5. MySQL Architecture Some internal components: António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 Each client connection gets its own thread within the server process. When clients (applications) connect to the MySQL server, the server needs to authenticate them. Before even parsing the query, though, the server consults the query cache, which only stores SELECT statements, along with their result sets. The storage engine does affect how the server optimizes query.
  • 6. MySQL Architecture Transactional properties (ACID): António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 MySQL Innodb storage engine fully supports transactions, a transaction can be viewed as a block of instructions that act are applied coherently to the database, in turn this means ACID standard compliance: Atomicity : Each transaction block is treated as a single instruction, all of the block must succeed or none. Consistency : Only valid data is written to the database, and the resulting state is valid. Isolation : While performing operations in a transaction block, other transactions don't see our changes. Durability : If the transaction returns a successful state it is persisted to the database.
  • 7. MySQL Architecture Storage engines: António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 MySQL supports several storage engines that act as handlers for different table types. MySQL storage engines include both those that handle transaction-safe tables and those that handle non-transaction-safe tables.
  • 8. MySQL Installation António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 Windows Installation wizard: http://dev.mysql.com/downloads/mysql/5.1.html#win32 Linux: Debian Based: apt-get install mysql-server-5.0 RPM based: rpm -ivh MySQL-server-*5.1.31-0.rhel3.i386.rpm YUM Based: yum install mysql-sever Gentoo Based: emerge mysql Macintosh: http://dev.mysql.com/downloads/mysql/5.1.html#macosx All in One Packages MAMP – Macintosh Apache MySQL and PHP http://www.mamp.info/en/index.php WAMP – Windows Apache MySQL and PHP http://www.wampserver.com/en/
  • 9. MySQL Overview MySQL Files: António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 wits In Linux the configuration file is typically located at /etc/mysql/my.cnf, but may vary for the different Linux flavours, this also applies to the database files them selves which are located in the /var/lib/MySQL. Regardless of the storage engine, every MySQL table you create is represented, on disk, by a .frm file, which describes the table’s format (i.e. the table definition). The file bears the same name as the table, with a .frm extension. The .frm format is the same on all platforms but in the description of the .frm format that follows, the examples come from tables created under the Linux operating system. /var/lib/mysql/db.frm #Table definition /var/lib/mysql/db.MYD #MyISAM data file /var/lib/mysql/db.MYI #MyISAM Index file /var/lib/mysql/ibdata1 #Innodb data file
  • 10. MySQL Command Line tools António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 On Linux the a user can interact with MySQL using the command line, in this interaction a user can create, update, delete and modify a MySQL database using the following command line tools mysql: general database and table interaction: mysql -u username -ppassword -h localhost db_name mysqldump: database backup mysqldump db_name > outputfile mysqlbinlog: binary log processing mysqlbinlog logfile_1 logfile_2 ... logfile_n > out.sql mysqlbinlog logfile_1 logfile_2 ... logfile_n | mysql mysql_install_db: database restore mysql_install_db
  • 11.
  • 12. MySQL Graphical tools MySQL query browser António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 MySQL query browser is a simple query tool used to interact with a MySQl database.
  • 13. MySQL Graphical tools phpmyadim António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 Phpmyadmin is a browser tool developed in php, that allows you to manage a mysql database.
  • 14. MySQL and Gaia António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 DbBenchmark is a simple java application that makes use of GaiaTools (currently outdated), and performs a series of standard tests. Class mapping: mdb.properties test control: dbbenchmark.properties.mysql_elem gaia.cu1.tools.db.username=username gaia.cu1.tools.db.password=password gaia.cu1.tools.db.driver=com.mysql.jdbc.Driver gaia.cu1.tools.db.url=jdbc:mysql://localhost:3306/gaia_test?rewriteBatchedStatements=true Running the tests: ant mysql_elem_random DbBenchmark
  • 15. MySQL and Gaia António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 MDBIngestorExtractor is a application that allows the extraction and ingestion “gbin” files, which are Class mapping: conf/mdb.properties MDB Extractor Ingestor properties: conf/ingestor.properties conf/extractor.properties gaia.cu1.tools.db.username=username gaia.cu1.tools.db.password=password gaia.cu1.tools.db.url=jdbc:mysql://localhost:3306/test gaia.cu1.tools.db.driver=com.mysql.jdbc.Driver Lauching the extactor/ingestor: bash ingest.sh bash extract.sh MDBIngestorExtractor
  • 16. MySQL queries António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09 Create a database: create database database_name; Display databases: show databases; Selecting a database use database_name Display tables: show tables Create a table: create table create table person (id int, person varchar (32) ) engine=engine_name Deleting a table: Drop table table_name Insert a value in a table: Insert into table_name.db_name (field1 , field 2...) Values (v1, v2, ...), (v1',v2'); View data all data in a table: select * from table name where cond = value Select data from two different tables: Select field1, field2 from tbl1, tbl2 where field3= field4; Sow create table statement: show create table tbl_name Show database variables: show variables;
  • 17.
  • 18. MySQL Graphical tools phpmysqladmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 19. MySQL Graphical tools phpmysqladmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 20. MySQL Graphical tools Phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 21. MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 22. MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 23. MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 24. MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 25. MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 26. MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09
  • 27. MySQL Graphical tools phpmyadmin and foreign keys António Amorim, Carlos Jesus. CU1 - DBWorkshop 9-10 /Feb/09