LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-18-2004, 09:37 AM   #1
duerra
Member
 
Registered: Oct 2003
Location: Where No One's Been... Spiral Out!
Distribution: FreeBSD
Posts: 201

Rep: Reputation: 30
MySQLDump and Cron


I cannot get mysqldump to work with cron. The following command works at command line, but not through cron:

mysqldump -uusername -ppassword --opt my_db | bzip2 > /tmp/my_db.sql.bz2

I have two problems with this.
1. It doesn't work. That's the biggest problem. I have even put in the full path to mysqldump, but that does not work, either.

2. I don't like passwords viewable in plain text format. So even if the dump above would work, ideas as to how to make it more secure would be appreciated.

Thanks!
 
Old 02-18-2004, 11:11 PM   #2
duerra
Member
 
Registered: Oct 2003
Location: Where No One's Been... Spiral Out!
Distribution: FreeBSD
Posts: 201

Original Poster
Rep: Reputation: 30
Anybody have any ideas?
 
Old 02-19-2004, 07:31 AM   #3
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
1) I'm not sure why the cron job isn't working. Are you sure cron is running? Is there anything in the logs that might shed some light?

2)Why don't your create a new mysql user specifically for this task. You could create one that doesn't have a password and then give it EXTREMELY limited privileges. Or keep the password for that user, but still severely restrict privileges. You're shooting to have ONLY those privileges needed to run mysqldump. That way if someone does get their hands on that username (and password if you choose), they wouldn't be able to do anything.
 
Old 02-19-2004, 08:01 AM   #4
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
I wrote a simple script for backing up a mysql database every day through cron and it works well, I still use it (although a little altered). You can find it in this post. I hope that helps a bit.


Håkan
 
Old 02-19-2004, 02:56 PM   #5
duerra
Member
 
Registered: Oct 2003
Location: Where No One's Been... Spiral Out!
Distribution: FreeBSD
Posts: 201

Original Poster
Rep: Reputation: 30
hw-tph, I will try something like that.

Hangdog42, I thought of the special user idea, but is there a way of giving a user mysqldump access, and nothing else??

I am sure cron is working, as I run cron functions an average of every 3-5 minutes for one task or another. It's simply the database backups that are being a pain.
 
Old 02-19-2004, 03:47 PM   #6
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
I don't think there is a way to give access to just mysqldump since it is a program that uses database functions, it isn't a database function itself. From what I can tell (and believe me I'm no expert), you probably need SELECT and FILE and maybe SHOW DATABASES and LOCK TABLES. You might try with just a minimal set like these (or heck, even see if it works with just USAGE) and add privileges until it works.

Oddly, if you do a little searching on mysqldump, it looks as if most people run it from their admin account. That suggests either they aren't using a cron job to do their backup or they haven't thought through the security implications.

<edit>
You might also limit these privileges to username@localhost. If you restrict the mysqldump user to localhost then if someone DOES learn the username, they would also have to have an account on the specific box to make use of it.
</edit>

Last edited by Hangdog42; 02-19-2004 at 03:59 PM.
 
Old 02-20-2004, 08:18 AM   #7
duerra
Member
 
Registered: Oct 2003
Location: Where No One's Been... Spiral Out!
Distribution: FreeBSD
Posts: 201

Original Poster
Rep: Reputation: 30
I'll check out the privileges stuff. Also, I already have my box locked down as far as hosts are concerned (localhost only), so I'm not too worried about that. I'll probably do exactly that, though - just keep adding on one logical privilege at a time until it works.
 
  


Reply



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
mysqldump questions wh33t Programming 1 10-24-2005 08:07 PM
about mysqldump javier_ccs Programming 3 08-08-2005 06:13 PM
restore using mysqldump sporkit Linux - Networking 2 05-26-2004 05:34 PM
mysqldump - backup *.* bpk Linux - Newbie 1 03-29-2004 04:42 PM
compressing mysqldump output linen0ise Linux - Newbie 0 07-28-2003 07:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:17 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration