Mysqldump抱怨选择的数据库,与命令行无关


20

Mysqldump抱怨我从未指定过的命令行选项。我没有外壳别名,也没有自定义的.my.cnf文件集。我究竟做错了什么?

使用--databaselong选项:

$ mysqldump --user cloud -p --database cloud > backup.mysqldb
Warning: Using unique option prefix database instead of databases is deprecated and  will be removed in a future release. Please use the full name instead.
Warning: mysqldump: ignoring option '--databases' due to invalid value 'cloud'
Warning: Using unique option prefix database instead of databases is deprecated and will be removed in a future release. Please use the full name instead.

使用--databaseslong选项:

$ mysqldump --user cloud -p --databases cloud > backup.mysqldb
Warning: Using unique option prefix database instead of databases is deprecated and will be removed in a future release. Please use the full name instead.
Warning: mysqldump: ignoring option '--databases' due to invalid value 'cloud'

使用--all-databaseslong选项:

$ mysqldump --user cloud -p --all-databases > backup.mysqldb
Warning: Using unique option prefix database instead of databases is deprecated and will be removed in a future release. Please use the full name instead.
Warning: mysqldump: ignoring option '--databases' due to invalid value 'cloud'

仅使用数据库名称:

$ mysqldump --user cloud -p cloud > backup.mysqldb
Warning: Using unique option prefix database instead of databases is deprecated and will be removed in a future release. Please use the full name instead.
Warning: mysqldump: ignoring option '--databases' due to invalid value 'cloud'

最后,什么都不做

$ mysqldump --user cloud -p > backup.mysqldb
Warning: Using unique option prefix database instead of databases is deprecated and will be removed in a future release. Please use the full name instead.
Warning: mysqldump: ignoring option '--databases' due to invalid value 'cloud'

1
你可能已经检查了这个已经,但没有在发现/etc/my.cnf/etc/mysql/conf.d或类似的位置?
Martijn Heemels,2015年

发布您/etc/my.cnf(及其包含)和$HOME/.my.cnf文件。
迈克尔·汉普顿

Answers:


27

.my.cnf选项文件中,可能已经为所有客户端指定了数据库参数,但是mysqldump不喜欢该参数。因此,请勿在选项文件中为所有客户端列出该参数。

例如,这是我解决该问题的方法,因此mysql客户端仍可以在不指定数据库的情况下正常工作(默认名称为“ walkin”),并且mysqldump不会抱怨:

之前:

$猫〜/ .my.cnf
[客户]
用户=根
主机= 127.0.0.1
密码=“ root”
数据库=走入

后:

$猫〜/ .my.cnf
[客户]
用户=根
主机= 127.0.0.1
密码=“ root”

[mysql]
数据库=走入

所以反直觉。感谢您清除此问题。
jchavannes

FWIW,这是一个(很旧的)错误报告:bugs.mysql.com/bug.php?id=18209
Dario Seidl

还有一个针对MariaDB的较新版本:mariadb.atlassian.net/browse/MDEV-7208
Dario Seidl
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.