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

DOC
PPT
PDF
MySQL for beginners
PPTX
MySql:Introduction
PPTX
SQL Basics
PDF
Models for hierarchical data
PPT
MySql slides (ppt)
PDF
MySQL: Indexing for Better Performance
MySQL for beginners
MySql:Introduction
SQL Basics
Models for hierarchical data
MySql slides (ppt)
MySQL: Indexing for Better Performance

What's hot (20)

PPTX
Chapter 1 introduction to sql server
PPT
SQL select clause
PDF
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
PPTX
Materialized Views and Secondary Indexes in Scylla: They Are finally here!
PPTX
Flask – Python
PDF
All about Zookeeper and ClickHouse Keeper.pdf
PDF
Basic SQL
PPTX
introdution to SQL and SQL functions
PDF
Sql server 2019 new features
PPTX
Sql joins inner join self join outer joins
PPTX
STRUCTURE OF SQL QUERIES
PDF
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
PDF
PDF
MySQL Performance Schema in Action
PDF
ClickHouse Deep Dive, by Aleksei Milovidov
PDF
Mastering PostgreSQL Administration
 
PDF
Introducing DataFrames in Spark for Large Scale Data Science
PDF
Oracle SQL Basics
PDF
[Pgday.Seoul 2020] SQL Tuning
PPTX
PostgreSQL Database Slides
Chapter 1 introduction to sql server
SQL select clause
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Materialized Views and Secondary Indexes in Scylla: They Are finally here!
Flask – Python
All about Zookeeper and ClickHouse Keeper.pdf
Basic SQL
introdution to SQL and SQL functions
Sql server 2019 new features
Sql joins inner join self join outer joins
STRUCTURE OF SQL QUERIES
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
MySQL Performance Schema in Action
ClickHouse Deep Dive, by Aleksei Milovidov
Mastering PostgreSQL Administration
 
Introducing DataFrames in Spark for Large Scale Data Science
Oracle SQL Basics
[Pgday.Seoul 2020] SQL Tuning
PostgreSQL Database Slides
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.