Skip to content

Commit

Permalink
Mysql dump instruction updated
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsiryk committed Feb 5, 2020
1 parent 4acd59d commit 750a24f
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions mysql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ Backup/restore mysql dump::
# create dump
mysqldump -u USER -pPASSWORD DATABASE > dump.sql

# create dump of several tables (not all database)
mysqldump -u USER -pPASSWORD DATABASE TABLE1 TABLE2 TABLE3 > dump_tables.sql

# create dump and archive it on fly
mysqldump -u USER -pPASSWORD DATABASE | gzip > dump.sql.gz

# with timestamp
mysqldump -u USER -pPASSWORD DATABASE | gzip > `date +dump.sql.%Y%m%d.%H%M%S.gz`

# restore from dump
mysql -u USER -p DATABASE < dump.sql

Expand All @@ -37,21 +46,21 @@ New ROOT password (tested on - mysql Ver 14.14 Distrib 5.5.52, for linux2.6 (x8

mysqladmin -p -u root password
mysqladmin -u root password NEWPASSWORD


::

# show slow queries
select * from mysql.slow_log\G

# show databases
mysqlshow -p
mysqlshow -p

# connect to remote DB
mysql -u <user>
-p # connect with pass
-h <ip>

# create DB
CREATE DATABASE users;

Expand Down Expand Up @@ -94,7 +103,7 @@ Update table cell::


Clear mysql command history::

> ~/.mysql_history


Expand All @@ -107,8 +116,8 @@ Repair crashed table::

# ERROR 144 - Table 'table_name' is marked as crashed and last (automatic?) repair failed
repair table <table_name>;


Rename table::

RENAME TABLE tbl_name TO new_tbl_name
Expand All @@ -121,15 +130,9 @@ SQLite
Show all tables::

SELECT name FROM sqlite_master WHERE type='table'


Show column list of the table::

PRAGMA table_info(table_name);





Show column list of the table::

PRAGMA table_info(table_name);

0 comments on commit 750a24f

Please sign in to comment.