Xavier Peña
Xavier Peña

Reputation: 7919

mysqldump is dumping undesired system tables

It is also dumping the correct ones, but they are at the end of a bunch of undesired ones.

The dump includes a bunch of "system" tables such as:

| column_stats |
| columns_priv |
| func |
...

I am using the root user to do the dump, like this:

"C:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump.exe" -u [user]-p [password] --databases "my-db-name" > dump.sql

I haven't been able to find any related info, I've mainly used mysqldump and column_stats as keywords.

Upvotes: 0

Views: 1304

Answers (2)

user4489658
user4489658

Reputation:

Finally I realised what's wrong here. Your parameter -p followed by blank space implies that you will type a password by the prompt "Enter password:", and your [password] is interpreted as a database name. Since there is no database named like your password, everything is dumped. From documentation:

--password[=password], -p[password]

The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, mysqldump prompts for one.

So, your command should be:

"C:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump.exe" -u [user] -ppassword "my-db-name" > dump.sql

(notice that here is no blank space between -p and your password),

or like this:

"C:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump.exe" -u [user] -p "my-db-name" > dump.sql

(here you input password from keyboard after pressing Enter).

Upvotes: 4

James
James

Reputation: 4716

The tables you mention all belongs to the mysql database, which is a system database. Is it perfectly acceptable to use mysqldump on that database, but an backup incomplete backup of that database might turns out to cause authentication/authorization/functional issues if you later you that dump to restore the database.

These tables should not appears inside a regular database. If they do exists there, it certainly indicates some prior mistake, and you should simply delete these tables.

If you simply want to perform that dump and don't want to investigate the root problem, It is also possible to tell mysqldump to ignore tables that exists but that you would like to exclude from a dump file. The option syntax is: --ignore-table=db_name.tbl_name. To exclude multiple tables, you can repeat that argument several time.

Upvotes: 1

Related Questions