0

I am trying to backup a mysql database using mysqldump command, but the message I get is mysqldump: option '--tables' cannot take an argument.

Here you are:

root@myhost:~# mysqldump mydatabase --user myuser --password mypassword
Warning: Using unique option prefix table instead of tables is deprecated and will be removed in a future release. Please use the full name instead.
mysqldump: option '--tables' cannot take an argument

I have tryed several argument combinations, but I finally discovered that the result is the same if I just try to get the command version or event with no arguments at all:

root@myhost:~# mysqldump --version
Warning: Using unique option prefix table instead of tables is deprecated and will be removed in a future release. Please use the full name instead.
mysqldump: option '--tables' cannot take an argument
root@myhost:~# mysqldump
Warning: Using unique option prefix table instead of tables is deprecated and will be removed in a future release. Please use the full name instead.
mysqldump: option '--tables' cannot take an argument

As you can see in the following lines, it is mysql server 5.5 running on debian 7.

System version:

root@myhost:~# uname -a
Linux myhost 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2+deb7u2 x86_64 GNU/Linux

mysql client version:

root@myhost:~# mysql --version
mysql  Ver 14.14 Distrib 5.5.35, for debian-linux-gnu (x86_64) using readline 6.2

mysql server version:

root@myhost:~# mysql -h localhost --user=myuser --password=mypassword mydatabase
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 75
Server version: 5.5.35-0+wheezy1-log (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye

I have looked for this problem on the web, but I cannot see anyone reporting this precise issue. I am not an expert on mysql but I can say it is a very simple install. Should you need more information, please tell me.

Thanks in advance, ivan

ivan
  • 11
  • 1
  • 3
  • It could be reading commands from mysql's [option files](https://dev.mysql.com/doc/refman/5.1/en/option-files.html). Are you sure that calling `mysqldump` is executing the real `mysqldump` and not some wrapper script (what does `which mysqldump` say)? Have you checked if `mysqldump` is [aliased to some other command](http://stackoverflow.com/questions/948008/linux-command-to-list-all-available-commands-and-aliases)? – DCoder Apr 22 '14 at 04:31
  • @DCoder, your comment on **option files** was the right clue to the solution. I cannot mark your comment as the accepted answer because it is not an answer itself. How can I thank? Btw. I wrote an answer myself so other users can use it. – ivan Apr 22 '14 at 11:44
  • You wrote a proper answer with more detail than I could - just mark your answer as accepted ;) – DCoder Apr 22 '14 at 11:54

2 Answers2

1

Following @DCoder indications I inspected /etc/mysql/my.cnf which, among others, contained

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock
table          = true

After removing table = true line from /etc/mysql/my.cnf, mysqldump command works as expected:

root@myhost:~# mysqldump
Usage: mysqldump [OPTIONS] database [tables]
OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help

My conclusion is that table=true option is not suitable for mysqldump command and must be removed from [client] in the options file. [client] section groups option settings applied to all client programs.

Should another command need that option set, it should be placed in another program section, neither in [mysqldump] nor in [client].

ivan
  • 11
  • 1
  • 3
0

Try this

mysqldump --tab = dir_name options db_name tbl_name

--tab writes each dumped file as a tab-delimited text file in the "dir_name" directory.

db_name is the db containing the table to the exported.

tbl_name is the table to be exported.

"options" part may include options such as --host or --user.

e.g.

mysqldump --tab = /tmp office contact
Ansh
  • 94
  • 4
  • Adding `--tab` argument did not make a difference and the message was the same. Thanks anyway. – ivan Apr 22 '14 at 10:56