InnoDB
NDBCLUSTER
NDBCLUSTER
CREATE DATABASE
CREATE TABLE
INSERT
InnoDB
MyISAM
MEMORY
InnoDB
MyISAM
InnoDB
NDB
SELECT
... INTO OUTFILE
LOAD DATA
INFILE
CREATE
INSERT
--tab
SELECT ... INTO
OUTFILE
InnoDB
MyISAM
InnoDB
mysqldump
InnoDB
InnoDB
--single-transaction
*.MYD
*.sdi
冲洗表 tbl_list
读锁;
InnoDB
SELECT * INTO OUTFILE
'
file_name
' FROM
tbl_name
CREATE TABLE
--tab
LOAD DATA
INFILE
--log-bin
FLUSH LOGS
FLUSH LOGS
LOAD DATA
INFILE
LOAD DATA
INFILE
--slave-load-tmpdir
tmpdir
MyISAM
REPAIR TABLE
FLUSH
TABLES WITH READ LOCK
mount vxfs
snapshot
UNLOCK
TABLES
--user
--password
InnoDB
InnoDB
InnoDB
InnoDB:笪塔巴涩没有关闭normally.innodb:开始恢复日志文件…InnoDB:启动日志扫描基于检查点的日志序列号atinnodb:0 13674004innodb:做回收:扫描了日志序列号0 13739520innodb:做回收:扫描了日志序列号0 13805056innodb:做回收:扫描了日志序列号0 13870592innodb:做回收:扫描了日志序列号0 13936128…InnoDB:做回收:扫描了日志序列号0 20555264innodb:做回收:扫描了日志序列号0 20620800innodb:做回收:扫描了日志序列号0 20664692innodb:1未提交的事务(S)必须滚backinnodb:启动回滚回滚未提交的transactionsinnodb:TRX没有16745innodb:TRX没有16745 completedinnodb回卷:对未提交的事务回滚:completedinnodb开始申请批日志记录到数据库…InnoDB:申请批completedinnodb:startedmysqld:准备连接
InnoDB
InnoDB
内核> mysqldump --all-databases --master-data --single-transaction > backup_sunday_1_PM.sql
.sql
INSERT
FLUSH
TABLES WITH READ LOCK
FLUSH
InnoDB
--single-transaction
InnoDB
MyISAM
--log-bin
--log-bin
RW光碟——1月10 guilhem guilhem 1277324 23时59 gbichot2-bin.000001-rw-rw--- 1 guilhem guilhem 10 11月4日23时59 gbichot2-bin.000002-rw-rw--- guilhem guilhem 79 1 11 11:06 1 508 gbichot2-bin.000003-rw-rw--- guilhem guilhem 11 11 1 guilhem gbichot2-bin.000004-rw-rw---:08年11月12日16时47分guilhem 220047446 gbichot2-bin.000005-rw-rw--- -1 11月14日guilhem guilhem 998412 10 1 guilhem gbichot2-bin.000006-rw-rw---:08年11月14日10时07分guilhem gbichot2-bin.index 361
FLUSH LOGS
.index
shell>mysqldump --single-transaction --flush-logs --master-data=2 \
--all-databases > backup_sunday_1_PM.sql
gbichot2-bin.000007
--flush-logs
--master-data
.sql
-- Position to start replication or point-in-time recovery from-- CHANGE MASTER TO MASTER_LOG_FILE='gbichot2-bin.000007',MASTER_LOG_POS=4;
gbichot2-bin.000007
gbichot2-bin.000007
gbichot2-bin.000008
gbichot2-bin.000008
shell>mysqldump --single-transaction --flush-logs --master-data=2 \
--all-databases --delete-master-logs > backup_sunday_1_PM.sql
PURGE BINARY
LOGS
shell> mysql < backup_sunday_1_PM.sql
gbichot2-bin.000007
shell> mysqlbinlog gbichot2-bin.000007 gbichot2-bin.000008 | mysql
--log-bin
shell> mysqlbinlog gbichot2-bin.000009 ... | mysql
InnoDB
--log-bin
--log-bin=
log_name
FLUSH LOGS
--tab
shell> mysqldump [arguments
] > file_name
--all-databases
内核> mysqldump --all-databases > dump.sql
--databases
内核> mysqldump --databases db1 db2 db3 > dump.sql
--databases
--all-databases
--databases
CREATE
DATABASE
USE
--add-drop-database
DROP DATABASE
CREATE DATABASE
shell> mysqldump --databases test > dump.sql
--databases
内核> mysqldump test > dump.sql
--databases
CREATE
DATABASE
USE
CREATE DATABASE
--add-drop-database
DROP DATABASE
shell> mysqldump test t1 t3 t7 > dump.sql
--all-databases
--databases
CREATE DATABASE
USE
内核> mysql < dump.sql
source
MySQL的> source dump.sql
CREATE DATABASE
USE
内核> mysqladmin create db1
shell> mysql db1 < dump.sql
mysql>CREATE DATABASE IF NOT EXISTS db1;
mysql>USE db1;
mysql>source dump.sql
For Windows PowerShell users: Because the "<" character is reserved for future use in PowerShell, an alternative approach is required, such as using quotescmd.exe /c "mysql
< dump.sql"
--tab=
dir_name
dir_name
t1.sql
.sql
CREATE TABLE
db1
shell> mysqldump --tab=/tmp db1
.txt
SELECT ... INTO
OUTFILE
FILE
CREATE
.sql
--tab
--tab
.sql
.txt
SELECT ... INTO
OUTFILE
--fields-optionally-enclosed-by=
char
--fields-enclosed-by
--fields-enclosed-by='"'
--fields-enclosed-by=0x22
\r\n
内核> mysqldump --tab=/tmp --fields-terminated-by=,
--fields-enclosed-by='"' --lines-terminated-by=0x0d0a db1
.sql
CREATE TABLE
.sql
.txt
内核> mysql db1 < t1.sql
内核> mysqlimport db1 t1.txt
LOAD DATA
INFILE
mysql>USE db1;
mysql>LOAD DATA INFILE 't1.txt' INTO TABLE t1;
LOAD DATA
INFILE
内核> mysqlimport --fields-terminated-by=,
--fields-enclosed-by='"' --lines-terminated-by=0x0d0a db1 t1.txt
mysql>USE db1;
mysql>LOAD DATA INFILE 't1.txt' INTO TABLE t1
->FIELDS TERMINATED BY ',' FIELDS ENCLOSED BY '"'
->LINES TERMINATED BY '\r\n';
shell>mysqldump db1 > dump.sql
shell>mysqladmin create db2
shell>mysql db2 < dump.sql
--databases
USE db1
shell> mysqldump --databases db1 > dump.sql
shell> mysql < dump.sql
--databases
CREATE DATABASE
USE
--databases
shell> mysqldump db1 > dump.sql
shell>mysqladmin create db1
shell>mysql db1 < dump.sql
--databases
--events
--routines
--triggers
--triggers
--skip-events
--skip-routines
--skip-triggers
--no-data
--no-create-info
CREATE
test
内核> mysqldump --no-data test > dump-defs.sql
内核> mysqldump --no-create-info test > dump-data.sql
--routines
--events
内核> mysqldump --no-data --routines --events test > dump-defs.sql
shell> mysqldump --all-databases --no-data --routines --events > dump-defs.sql
shell> mysql < dump-defs.sql
shell> mysqldump --all-databases --no-create-info > dump-data.sql
shell> mysql < dump-data.sql
\0
--binary-mode
--log-bin
--log-bin
mysql> SHOW BINARY LOGS;
mysql> SHOW MASTER STATUS;
shell> mysqlbinlog binlog_files
| mysql -u root -p
shell> mysqlbinlog binlog_files
| more
shell>mysqlbinlog
shell> ...binlog_files
> tmpfileedit tmpfile
...
DROP DATABASE
内核> mysql -u root -p < tmpfile
shell>mysqlbinlog binlog.000001 | mysql -u root -p # DANGER!!
shell>mysqlbinlog binlog.000002 | mysql -u root -p # DANGER!!
CREATE TEMPORARY
TABLE
shell> mysqlbinlog binlog.000001 binlog.000002 | mysql -u root -p
shell>mysqlbinlog binlog.000001 > /tmp/statements.sql
shell>mysqlbinlog binlog.000002 >> /tmp/statements.sql
shell>mysql -u root -p -e "source /tmp/statements.sql"
--skip-gtids
shell>mysqlbinlog --skip-gtids binlog.000001 > /tmp/dump.sql
shell>mysqlbinlog --skip-gtids binlog.000002 >> /tmp/dump.sql
shell>mysql -u root -p -e "source /tmp/dump.sql"
--start-datetime
--stop-datetime
DATETIME
内核> mysqlbinlog --stop-datetime="2005-04-20 9:59:59" \
/var/log/mysql/bin.123456 | mysql -u root -p
--stop-datetime
shell>mysqlbinlog --start-datetime="2005-04-20 10:01:00" \
/var/log/mysql/bin.123456 | mysql -u root -p
shell> mysqlbinlog /var/log/mysql/bin.123456 > /tmp/mysql_restore.sql
/tmp/mysql_restore.sql
--start-position
--stop-position
shell>mysqlbinlog --start-datetime="2005-04-20 9:55:00" \
--stop-datetime="2005-04-20 10:05:00" \
/var/log/mysql/bin.123456 > /tmp/mysql_restore.sql
/tmp
shell>mysqlbinlog --stop-position=368312 /var/log/mysql/bin.123456 \
| mysql -u root -p
shell>mysqlbinlog --start-position=368315 /var/log/mysql/bin.123456 \
| mysql -u root -p
SET
TIMESTAMP
MyISAM
.MYI
MyISAM
MyISAM
MyISAM
CHECK TABLE
MyISAM
REPAIR TABLE
MyISAM
OPTIMIZE TABLE
MyISAM
ANALYZE TABLE
MyISAM
MyISAM
tbl_name
| |
|
.MYD
--quick
.MYD
.MYD
.MYD
--quick
.MYD
--quick
MyISAM
-s
-e
-v
-i
MyISAM
.MYD
CHECK TABLE
REPAIR TABLE
tbl_name
.MYInnn
nnn
nnn
nnn
shell> perror 126 127 132 134 135 136 141 144 145
MySQL error code 126 = Index file is crashed
MySQL error code 127 = Record-file is crashed
MySQL error code 132 = Old database file
MySQL error code 134 = Record was already deleted (or record file crashed)
MySQL error code 135 = No more room in record file
MySQL error code 136 = No more room in index file
MySQL error code 141 = Duplicate unique key or constraint on write or update
MySQL error code 144 = Table is crashed and last repair failed
MySQL error code 145 = Table was marked as crashed and should be repaired
ALTER TABLE
AVG_ROW_LENGTH
修改表 tbl_name
MAX_ROWS=xxx
AVG_ROW_LENGTH=yyy
;
SHOW CREATE TABLE
-s
--update-state
out
of memory
tbl_name
tbl_name
tbl_name
sort_buffer_size
key_buffer_size
out of memory
shell> mysql db_name
MySQL的> SET autocommit=1;
MySQL的> TRUNCATE TABLE
tbl_name
;MySQL的> quit
REPAIR TABLE
tbl_name
USE_FRMREPAIR TABLE
shell> myisamchk -r tbl_name
OPTIMIZE TABLE
OPTIMIZE TABLE
OPTIMIZE
TABLE
--analyze
--sort-index
--sort-records=
index_num
index_num
SELECT
MyISAM
CHECK TABLE
REPAIR TABLE
-s
--silent
MyISAM
MyISAM
--myisam-recover-options
crontab
35 * 0 * 0 /path/to/myisamchk
-快-沉默 /path/to/datadir
/ * / *。我
MyISAM
VARCHAR
BLOB
TEXT
OPTIMIZE TABLE
shell> myisamchk -r -s --sort-index --myisam_sort_buffer_size=16M */*.MYI