Skip to content

A console tool that dumps MySQL tables as whatever-separated data.

License

Notifications You must be signed in to change notification settings

tzvetkoff/mysqldumptab

Folders and files

NameName
Last commit message
Last commit date
Jun 4, 2015
Jul 31, 2015
Jun 10, 2015
Jun 4, 2015
Jun 4, 2015
Jul 31, 2015
Nov 18, 2014
Jul 30, 2015
Jul 31, 2015
Jun 4, 2015
Jul 31, 2015

Repository files navigation

mysqldumptab

A console tool that dumps MySQL tables as whatever-separated data.

TL;DR;

mysqldump --tab actually calls SELECT * INTO OUTFILE on the server, so it's not really useful when you need to dump a table from a remote server.

mysqldumptab leverages that as it dumps a table in the exact same format as SELECT INTO OUTFILE but does that on the client side.

Dependencies

A compiler.

MySQL client libraries and build-essential or devel, depending on your OS.

Installation

Just like any software that comes with configure scripts:

./bootstrap
./configure --disable-shared --prefix=/usr/local
make install clean

Tweaking

The configure script provides several options for tweaking:

Option Description
--disable-shared Link the resulting binary against static libraries only. Recommended.
--with-mysql-config Provide an alternate path to mysql_config.
--with-buffer-block-size=VAL Set the growing output buffer block size to VAL. The default value is 0x4000 (16KB).

Usage

Some options like -uphPs are the same as mysqldump.

If you pass -p with no argument, you'll get a password prompt.

Options that take characters support hex format - --fields-escaped-by=0x5c.

Usage:
  mysqldumptab [options] <database> <table>

Options:
  -u, --username                    set mysql user []
  -p, --password                    set mysql password []
  -h, --host                        set mysql host [localhost]
  -P, --port                        set mysql port [3306]
  -s, --socket                      set mysql socket
  -C, --charset                     set connection character set [UTF8]
  -o, --output-file                 write output to file instead of stdout

  -H, --help                        display this help and exit
  -V, --version                     print version information and exit
  -M, --mysql-info                  print mysql client version and exit

  -B, --buffer                      buffer query result set
  -S, --select                      fields to select
  -W, --where                       where clause
  -O, --order                       order by
  -G, --group                       group by
  -A, --having                      having clause

  --fields-terminated-by            terminate output fields with the given string
  --fields-enclosed-by              enclose output fields with the given character
  --fields-optionally-enclosed-by   optionally enclose output fields with the given character
  --fields-escaped-by               escape output fields with the given character
  --lines-terminated-by             terminate lines with the given string

Compatibility

mysqldumptab aims to be 100% compatible with the output SELECT INTO OUTFILE produces.

If not, please file a bug.

Speed

Speed comparisons are rather subjective but when running on the same host, mysqldumptab is ~25% faster than mysqldump and SELECT INTO OUTFILE.

# mysqldump -uroot test_db table_with_500k_records > out.sql
real    0m1.810s
user    0m1.608s
sys     0m0.178s

# mysqldump -uroot --tab=out test_db table_with_500k_records
real    0m1.810s
user    0m0.006s
sys     0m0.002s

# mysqldumptab -uroot test_db table_with_500k_records > out.tab
real    0m1.333s
user    0m0.590s
sys     0m0.216s

Bugs

!@#$

About

A console tool that dumps MySQL tables as whatever-separated data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published