LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 11-28-2007, 04:56 AM   #1
Roosta21
Member
 
Registered: Aug 2004
Distribution: Fedora core 4
Posts: 55

Rep: Reputation: 15
One line Mysql backup


Hi.

I am attempting to backup my Mysql database.. by adding a command to a script

mysqldump --user testuser --password testpassword --all-databases> alldatabases.sql

But when i run this command as above it doesn't back up the databases it just creates an sql file that is about 203 bytes.. with the below info in

Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help



If i run the command without the password

mysqldump --user testuser --all-databases> alldatabases.sql

Which then prompts me for a password after i put in the password it backs up fine and creates 60 meg sql file..

Is this a mysql setting i can change?

Last edited by Roosta21; 11-28-2007 at 04:57 AM.
 
Old 11-28-2007, 08:35 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,897

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
You must use -p followed immediately with the password (i.e. without a space). The same goes for the --user option. So you can change your command to:
Code:
mysqldump -utestuser -ptestpassword --all-databases> alldatabases.sql
 
Old 11-28-2007, 10:47 AM   #3
weisso5
Member
 
Registered: Oct 2007
Location: New York City
Distribution: Gentoo, FC
Posts: 133

Rep: Reputation: 16
Another Hint:

When doing all databases dump the file could be really large, the command i use to keep the size down is:

mysqldump -u username -ppassword --all-databases | bzip2 > /mnt/backup/database_backups/mysql_backup.sql
 
Old 11-28-2007, 12:34 PM   #4
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
When using --password you need to use it like:

--password=<password>
 
Old 11-29-2007, 09:30 AM   #5
weisso5
Member
 
Registered: Oct 2007
Location: New York City
Distribution: Gentoo, FC
Posts: 133

Rep: Reputation: 16
I forgot to add to my earlier hint that you can change bzip2 into gzip if you want but the compression will be less.

Last edited by weisso5; 11-29-2007 at 09:32 AM.
 
Old 11-29-2007, 10:01 AM   #6
predatorz
Member
 
Registered: Mar 2007
Posts: 58

Rep: Reputation: 15
Script for MySQL backup, works fine.

http://sourceforge.net/projects/automysqlbackup/
 
Old 12-06-2007, 10:23 AM   #7
Roosta21
Member
 
Registered: Aug 2004
Distribution: Fedora core 4
Posts: 55

Original Poster
Rep: Reputation: 15
Guys thank you very much for this advice it worked a treat!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql works from command line, but mysql.sock (13) error from php.. leif_84 Linux - Server 0 07-23-2007 12:59 PM
Command line: How do I backup files modified after a specific date only rm_-rf_windows Linux - General 2 06-28-2007 08:34 PM
Command line tape backup software tensigh Linux - Software 4 06-21-2007 04:06 PM
LXer: MySQL Backup And Recovery With mysql-zrm On Debian Sarge LXer Syndicated Linux News 0 09-28-2006 08:21 AM
backup configuration file for webmin via command line? paul_mat Linux - Networking 1 02-05-2006 01:54 PM


All times are GMT -5. The time now is 12:00 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration