SlideShare a Scribd company logo
MySQL Cheat Sheet.EN                                                newest original japanese sheet available at: http://bit.ly/73I1bQ | MySQL Official Document: http://dev.mysql.com/doc

               Use my.cnf for instance settings                       you can choose different
                                                                                                     Table Ops                     Command
                                                                    storage engine for each table
  connection                                                                                         List existing tables          mysql> SHOW [FULL] TABLES;
                                                  .......
   threads                                                                 Storage Engine
                                                                                                     Show table information        mysql> SHOW TABLE STATUS [LIKE 'table1'];
 Query cache Optimizer Thread Cache Binary Log
                                                                                                                                   mysql> DESC table1;
                                                                                             ...     Check table properties
                                                                                                                                   mysql> SHOW CREATE TABLE table1 G
 db1                                    db2                         Buffer Pool
                                                                                         BG                                        mysql> CREATE TABLE table1 [columns...]
  table1     table2   table3     ...     table1      table2   ...                      threads       Create table
                                                                      Disk I/O                                                     ENGINE=desired storage engine
                                                                                                     Modify table properties       mysql> ALTER TABLE table1 ...
                                                                      Data File      Log File        Transaction Ops               Command
       Storage             Storage                 Storage
           Engine              Engine              Engine                                            Switch off auto commit        mysql> SET AUTOCOMMIT=0;
                                                                                                                                   mysql> START TRANSACTION;
                                                                                                     Start a transaction
Basic Ops                               Command                                                                                    mysql> BEGIN;
                                        shell> mysql --version                                       Execute SQL statement mysql> SELECT ... (any SQL statement)
Check mysqld version
                                        mysql> SELECT VERSION;                                       Commit                        mysql> COMMIT;
Check set values                        shell> my_print_default_mysqld                               Place a save point            mysql> SAVEPOINT name of save point;
Show compile options                    shell> mysqlbug                                              Rollback                      mysql> ROLLBACK;
Connect to MySQL server                 shell> mysql -u user -p db1                                  Admin Ops                     Command
Instance Level Ops                      Command                                                      Export to a file               mysql> SELECT ... INTO OUTFILE 'file name';
                                        shell> mysqld_safe &                                                                       mysql> SET @@character_set_database=binary;
Start mysqld                            shell> sudo /etc/init.d/mysqld start                         Read from a file               mysql> LOAD DATA INFILE 'file name' INTO
                                        shell> service mysqld start                                                                TABLE 'table name';
                                        shell> mysqladmin -uroot -p shutdown                                                       mysql> mysqldump [options] -B db1,db2 >
Stop mysqld                             shell> sudo /etc/init.d/mysqld stop                                                        dump.sql
                                        shell> service mysqld stop                                   Backup                        --single-transactions (snapshot using MVCC)
                                                                                                                                   --master-data=2 (output position of binary log)
                                        shell> mysqladmin -u root -p status
Check status                                                                                                                       --flush-logs (switch binary logs)
                                        mysql> s
                                                                                                     Restore                       mysql> mysql db1 < dump.sql
Show system variables                   mysql> SHOW GLOBAL VARIABLES;
                                                                                                     Defrag                        mysql> OPTIMIZE TABLE table1;
Show status variables                   mysql> SHOW GLOBAL STATUS;
                                                                                                     Update Statistics Info        mysql> ANALYZE TABLE table1;
List connected clients                  mysql> SHOW [FULL] PROCESSLIST;
                                                                                                     Switch logs                   mysql> FLUSH LOGS;
Database Ops                            Command
                                                                                                     Export table                  mysql> FLUSH TABLES [WITH READ LOCK];
List existing databases                 mysql> SHOW DATABASES;
Create a database                       mysql> CREATE DATABASE db1;                                 This work builds upon "MySQL Cheat Sheet" (http://bit.ly/73I1bQ) BY Mikiya Okuno, 2009,
                                                                                                    and is licensed under a Creative Commons: Attribution-ShareAlike liecense.
Switch database to use                  mysql> USE db1;                                             Translated to English by Dominick Chen, 2010.

More Related Content

PDF
Python programming : Inheritance and polymorphism
PDF
Python programming : Abstract classes interfaces
PDF
Modélisation de données pour MongoDB
PDF
Création de bases de données
PPTX
Cohesion et couplage
PPTX
Advance oops concepts
Python programming : Inheritance and polymorphism
Python programming : Abstract classes interfaces
Modélisation de données pour MongoDB
Création de bases de données
Cohesion et couplage
Advance oops concepts

What's hot (20)

PPTX
Image Segmentation Using PYTHON
PDF
Le protocole HTTP
PDF
Android-Tp1: éléments graphiques de base et intents
PPTX
Contraintes uml
PPT
Object Oriented Language
PDF
BigData_TP5 : Neo4J
PPTX
Flask – Python
PPT
Css advanced – session 4
PPT
Hibernate architecture
PPT
Chapter 13 - Recursion
PPTX
Introduction à l’orienté objet en Python
PDF
Chapitre 4 heritage et polymorphisme
PPTX
Modele mvc
PPSX
Java Object Oriented Programming
PPTX
Python/Flask Presentation
PDF
Clean architecture
PPTX
Computer Science:Java jdbc
PPTX
Gof design patterns
PPTX
Laravel Eloquent ORM
PPTX
الوراثة في الجافا
Image Segmentation Using PYTHON
Le protocole HTTP
Android-Tp1: éléments graphiques de base et intents
Contraintes uml
Object Oriented Language
BigData_TP5 : Neo4J
Flask – Python
Css advanced – session 4
Hibernate architecture
Chapter 13 - Recursion
Introduction à l’orienté objet en Python
Chapitre 4 heritage et polymorphisme
Modele mvc
Java Object Oriented Programming
Python/Flask Presentation
Clean architecture
Computer Science:Java jdbc
Gof design patterns
Laravel Eloquent ORM
الوراثة في الجافا
Ad

Viewers also liked (20)

PDF
Ms office 2010 complete
PDF
Python3 cheatsheet
ODP
HTML5 and Semantic Web
PDF
Introduction to HTML5 and CSS3
KEY
Design trends - from html tables to semantic html5
DOCX
Java cheat sheet
KEY
Semantic HTML5
PDF
Java cheat sheet
PDF
Cheat Sheet java
PDF
MySQL Cheat Sheet
PPT
Cheat sheets for coding
PDF
Google Cheat Sheet
PPT
Install Word Press with xampp
PPTX
Extending ADDM Discovery to Firewalls, Applications and Routers
PDF
PostgreSQL Streaming Replication Cheatsheet
PPTX
Introduction to php
PDF
Webentwicklung mit PHP und MySQL
PDF
みんなの日本語初級 2 標準問題集
PPT
Twitter Guide Cheat Sheet
PPT
Update CMDB Using Discovery Topology (BMC ADDM)
Ms office 2010 complete
Python3 cheatsheet
HTML5 and Semantic Web
Introduction to HTML5 and CSS3
Design trends - from html tables to semantic html5
Java cheat sheet
Semantic HTML5
Java cheat sheet
Cheat Sheet java
MySQL Cheat Sheet
Cheat sheets for coding
Google Cheat Sheet
Install Word Press with xampp
Extending ADDM Discovery to Firewalls, Applications and Routers
PostgreSQL Streaming Replication Cheatsheet
Introduction to php
Webentwicklung mit PHP und MySQL
みんなの日本語初級 2 標準問題集
Twitter Guide Cheat Sheet
Update CMDB Using Discovery Topology (BMC ADDM)
Ad

Similar to MySQL Cheat Sheet (20)

PDF
MariaDB training
PPTX
My sql administration
PDF
Summary tables with flexviews
PDF
MySQL replication & cluster
PDF
MySQL for Oracle DBAs
PDF
MySQL Replication Basics -Ohio Linux Fest 2016
PPT
Raj mysql
PDF
Get mysql clusterrunning-windows
PPTX
ConFoo MySQL Replication Evolution : From Simple to Group Replication
PDF
Explaining the MySQL Explain
PPTX
My sql failover test using orchestrator
PPTX
MySQL Replication Evolution -- Confoo Montreal 2017
PPTX
My SQL Portal Database (Cluster)
PDF
Mysql wp cluster_quickstart_windows
ODT
Mysql
PDF
MySQL Replication Update -- Zendcon 2016
PPTX
MySQL Replication Overview -- PHPTek 2016
DOCX
MariaDB training
My sql administration
Summary tables with flexviews
MySQL replication & cluster
MySQL for Oracle DBAs
MySQL Replication Basics -Ohio Linux Fest 2016
Raj mysql
Get mysql clusterrunning-windows
ConFoo MySQL Replication Evolution : From Simple to Group Replication
Explaining the MySQL Explain
My sql failover test using orchestrator
MySQL Replication Evolution -- Confoo Montreal 2017
My SQL Portal Database (Cluster)
Mysql wp cluster_quickstart_windows
Mysql
MySQL Replication Update -- Zendcon 2016
MySQL Replication Overview -- PHPTek 2016

More from Chen Dominique (8)

PDF
Ncc day2 talk
PDF
Cybernetic Serendipity, reloaded
PDF
コミュニティとしてのオープンプロダクトの展開
PDF
TEDxKids@Chiyoda 2012
PDF
"FabLife"を読む
PDF
Communication Design for creating Creative Circulation | 創造の循環を生むためのコミュニケーション...
PDF
Free Hardware and Open Processes | フリー・ハードウェアとオープン・プロセス
PDF
Power Of Open and Beyond / オープンネスの先にあるもの
Ncc day2 talk
Cybernetic Serendipity, reloaded
コミュニティとしてのオープンプロダクトの展開
TEDxKids@Chiyoda 2012
"FabLife"を読む
Communication Design for creating Creative Circulation | 創造の循環を生むためのコミュニケーション...
Free Hardware and Open Processes | フリー・ハードウェアとオープン・プロセス
Power Of Open and Beyond / オープンネスの先にあるもの

MySQL Cheat Sheet

  • 1. MySQL Cheat Sheet.EN newest original japanese sheet available at: http://bit.ly/73I1bQ | MySQL Official Document: http://dev.mysql.com/doc Use my.cnf for instance settings you can choose different Table Ops Command storage engine for each table connection List existing tables mysql> SHOW [FULL] TABLES; ....... threads Storage Engine Show table information mysql> SHOW TABLE STATUS [LIKE 'table1']; Query cache Optimizer Thread Cache Binary Log mysql> DESC table1; ... Check table properties mysql> SHOW CREATE TABLE table1 G db1 db2 Buffer Pool BG mysql> CREATE TABLE table1 [columns...] table1 table2 table3 ... table1 table2 ... threads Create table Disk I/O ENGINE=desired storage engine Modify table properties mysql> ALTER TABLE table1 ... Data File Log File Transaction Ops Command Storage Storage Storage Engine Engine Engine Switch off auto commit mysql> SET AUTOCOMMIT=0; mysql> START TRANSACTION; Start a transaction Basic Ops Command mysql> BEGIN; shell> mysql --version Execute SQL statement mysql> SELECT ... (any SQL statement) Check mysqld version mysql> SELECT VERSION; Commit mysql> COMMIT; Check set values shell> my_print_default_mysqld Place a save point mysql> SAVEPOINT name of save point; Show compile options shell> mysqlbug Rollback mysql> ROLLBACK; Connect to MySQL server shell> mysql -u user -p db1 Admin Ops Command Instance Level Ops Command Export to a file mysql> SELECT ... INTO OUTFILE 'file name'; shell> mysqld_safe & mysql> SET @@character_set_database=binary; Start mysqld shell> sudo /etc/init.d/mysqld start Read from a file mysql> LOAD DATA INFILE 'file name' INTO shell> service mysqld start TABLE 'table name'; shell> mysqladmin -uroot -p shutdown mysql> mysqldump [options] -B db1,db2 > Stop mysqld shell> sudo /etc/init.d/mysqld stop dump.sql shell> service mysqld stop Backup --single-transactions (snapshot using MVCC) --master-data=2 (output position of binary log) shell> mysqladmin -u root -p status Check status --flush-logs (switch binary logs) mysql> s Restore mysql> mysql db1 < dump.sql Show system variables mysql> SHOW GLOBAL VARIABLES; Defrag mysql> OPTIMIZE TABLE table1; Show status variables mysql> SHOW GLOBAL STATUS; Update Statistics Info mysql> ANALYZE TABLE table1; List connected clients mysql> SHOW [FULL] PROCESSLIST; Switch logs mysql> FLUSH LOGS; Database Ops Command Export table mysql> FLUSH TABLES [WITH READ LOCK]; List existing databases mysql> SHOW DATABASES; Create a database mysql> CREATE DATABASE db1; This work builds upon "MySQL Cheat Sheet" (http://bit.ly/73I1bQ) BY Mikiya Okuno, 2009, and is licensed under a Creative Commons: Attribution-ShareAlike liecense. Switch database to use mysql> USE db1; Translated to English by Dominick Chen, 2010.