6

I have an issue when specific database and table using mysqldump.

First in IP Server (111.111.1.1 Fake server) There are 3 databases which are DBname1,DBname2 and DBname3

I need to dump the table mm_cash which in DBname2

The query that I use:

mysqldump --host=111.111.1.1 --user=fakeuser --password=fakepas --databases=DBname2 --tables=mm_cash --where="true limit 1" > D:\test.txt 

However, I got this error:

mysqldump: [Warning] Using a password on the command line interface cenbe insecure. mysqldump: [Warning] mysqldump: ignoring option '--databases' due to invalid value 'DBname2' mysqldump: [Error] mysqldump: option '--tables' cannot take an argument

For 2nd error,I have already checked this is an correct database name. Could anyone please help?

2 Answers 2

7

The problem is the way you are using the options --databases and --tables. In reality you shouldn't use them but you have to put the database name and the table at the end of the command as specified in the help :

Usage: mysqldump [OPTIONS] database [tables] 

Try this:

mysqldump --host=111.111.1.1 --user=fakeuser --password=fakepas --where="true limit 1" DBname2 mm_cash > D:\test.txt 
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks,it's work.By the way,Please advice if I would like file that contains only column header and data. Please see this script mysqldump --host=111.111.1.1 --column-statistics=0 --skip-triggers --extended-insert --compact --no-create-info --skip-lock-tables --user=fakeusesr --password=fakepas --where="true limit 100" DBname2 mm_cash > D:\test.txt
Something like this ? mysql -p --silent -e "select * from mm_cash " DBname2
Yes,that's what i am looking for,Thank a lot.The last issue,Could you please advice for this query mysql -p --silent -e "select * from mm_cash " DBname2, I need to seperated field by using '|'.Now it's tap.I google and found --fields-terminated-by but it doesn't work.mysql -h -u -p -e "select * from table" databasename --fields-terminated-by='|' --lines-terminated-by='\n'> D:\test.txt
I don't think it's possible to change the delimeter. But you can try the -t parameter: mysql -p -t --silent -e "select * from mm_cash " DBname2
What isn't working? the last command? What version of mysql client are you using? Check the corresponding flag with mysql -h. Mine says: "-t, --table Output in table format".
|
4

Try this...

mysqldump -u fakeuser -p DBname2 mm_cash > DBname2_mm_cash.sql 

1 Comment

Thanks,it's work.By the way,Please advice if I would like file that contains only column header and data. Please see this script mysqldump --host=111.111.1.1 --column-statistics=0 --skip-triggers --extended-insert --compact --no-create-info --skip-lock-tables --user=fakeusesr --password=fakepas --where="true limit 100" DBname2 mm_cash > D:\test.txt

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.