Mysqldump 抱怨我从未指定的命令行选项。我没有 shell 别名,也没有设置自定义 .my.cnf 文件。我做错了什么?
使用--database
长选项:
$ 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.
使用--databases
长选项:
$ 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-databases
长选项:
$ 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
在您的.my.cnf
选项文件中,您可能为所有客户端指定了数据库参数,但 mysqldump 不喜欢该参数。因此,不要在您的选项文件中为所有客户端列出该参数。
例如,下面是我解决问题的方法,因此 mysql 客户端仍然可以工作,而无需指定数据库(默认为名称“walkin”)并且 mysqldump 不会抱怨:
前:
$ cat ~/.my.cnf [客户] 用户=root 主机=127.0.0.1 密码=“root” 数据库=walkin
后:
$ cat ~/.my.cnf [客户] 用户=root 主机=127.0.0.1 密码=“root” [mysql] 数据库=walkin