stevland
stevland

Reputation: 119

'unknown option -W' error when running mysqldump

I am trying to create a backup of a database.

mysqldump -u ost-v1-11-x -xWt1z0*8 ost-v1-11-x_ > /master-db/ost-v1-11-x__.sql

But this results in an error:

mysqldump: unknown option '-W'

I have verified all of the paths / names / password.

I can use the same code to successfully backup another database on the same server and within the same user account.

I have tried Googling the '-W' error to no avail.

Upvotes: 0

Views: 2074

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562911

When you prefix a flag with a single -, it's called a clustered option. Each letter following the - is interpreted as a flag.

This is how you can use UNIX/Linux commands like:

ls -lar

This means the same thing as:

ls -l -a -r

So when you used this flag argument:

-xWt1z0*8

It assumed you mean you were using a cluster of options:

-x -W -t -1 -z -0 -* -8

The -x option is recognized by mysqldump. It's a short alias for --lock-all-tables.

Then the program proceeded to the next option you gave: -W. On Windows, this is a short alias for the --pipe option, but on UNIX/Linux/Mac, the option is not recognized.

I'm not sure what you intended by the option -xWt1z0*8 but I would guess that's supposed to be a password. If so, you should use the -p flag, followed by your password.

mysqldump -u ost-v1-11-x -pxWt1z0*8 ...

Here's where mysqldump does something that breaks the conventions for clustered options. The -p option is prefixed with a single -, and yet the letters that follow it are not also interpreted as options. They're interpreted as the password.

If you want to make your usage more clear, stop using short options. Use only long option format:

mysqldump --user=ost-v1-11-x --password=xWt1z0*8 ...

Upvotes: 2

Related Questions