Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting warning ignoring option '--databases' due to invalid value 'testdatabase' in mysql while importing data

Tags:

linux

mysql

i am getting warning ignoring option '--databases' due to invalid value 'testdatabase' in mysql while importing sql data into a database.Its working fine when I do it on my local machine but same is not working on remote server through putty.I have copied the file on remote server. heres my query

 mysqldump -u root -p testdatabase < /home/user1/mydump.sql

remote machine(linux) mysql version : Ver 14.14 Distrib 5.6.14

local machine(windows 7) mysql version : Ver 14.14 Distrib 5.6.21

like image 921
nitin raikar Avatar asked Mar 17 '23 19:03

nitin raikar


2 Answers

I got the same error message from mysqldump, except in my case the error was due to MySQL bug #41209.

If you have a ~/.my.cnf that looks something like this

[client]
database = testdatabase

[mysqldump]
databases = false

And you ran mysqldump > dump.sql, you would get the error message

mysqldump: ignoring option '--databases' due to an invalid value 'testdatabase'

The error comes about because mysqldump reads both the [client] and [mysqldump] sections of the config file. Due to the way the MySQL CLI programs do option parsing, mysqldump assumes database (i.e. the --database option recognized by mysql) is short for databases (i.e. the --databases option recognized by mysqldump), hence the error. It is a long-standing bug.

Ordinarily, the --database option for the client, mysql, specifies the name of the database to operate on, while the --databases option for mysqldump (note the s at the end) is a boolean switch that means

consider all 'name' arguments as databases to dump, rather than inferring the database name as being the first non-option argument on the command line, and the remaining 'names' as tables.

How do you solve it?

  1. Remove database from the [client] section of your ~/.my.cnf and specify it as an argument to mysql instead
  2. Alternatively, look into the --defaults-group-suffix option; make yourself a shell alias if you feel like that option is too much to remember/type
like image 115
TheDudeAbides Avatar answered Mar 19 '23 10:03

TheDudeAbides


If its not getting reflected even though you tried @rups solution then there might be possibilty that database names are different across your machines. Check if database name in the host machine and remote machine is same.if no then make relevant changes to the database name and table name.

like image 28
nikhil Avatar answered Mar 19 '23 09:03

nikhil