LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-14-2003, 05:54 AM   #1
wimpie_net
LQ Newbie
 
Registered: Jul 2003
Location: The Netherlands
Distribution: Debian 2.2.20-idepci
Posts: 8

Rep: Reputation: 0
MYSQL backup problem


Hi,

The harddisk of my server crached recently.
Booting from harddisk became impossible.
I've put the disk in my XP desktop and booted it up with Knoppix.
I can see al my files now and I backed up my home dirs.
The only thing I want to backup now are the MYSQL databases.
But when I approche the files they are locked and I can't move them.
Does anyone has a solution for my problem?

I'm not an expert with this stuff so I hope you guys can help me.

Thnks in advance...
 
Old 10-14-2003, 06:19 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
To export a MySQL database to a text file with SQL that can easily be inserted into another MySQL database, simply run:
mysqldump -uUsername -pPassword dbName > outPutFilename.sql

In the example above, Username is your MySQL user, Password is your MySQL password, dbName is the name of the database you want to back up and outPutFilename.sql is what the resulting SQL file will be called.

To recreate the database on another host (or after a new install) simply do:
mysql -uUser -pPass dbName < backup.sql

You have to create the dbName database (just an empty database - mysqladmin -p create dbName) before you run the above command.

I have a script that I run nightly using cron to back up a database. Copy and paste, edit as needed and save. Make it executable and add it to cron if you want nightly backups.

Code:
#!/bin/bash
dbuser=username
dbpass=password
dbname=dbname
output=/home/hw/backups/
datum=`date +%Y%m%d`
mysqldump -u"$dbuser" -p"$dbpass" $dbname > "$output"/"$dbname"_"$datum".sql
bzip2 "$output"/"$dbname"_"$datum".sql
rm -f "$output"/"$dbname"_"$datum".sql
The script will create backups in the /home/hw/backups dir and compress them (a *lot*) using bzip2. The filenames will be dbname_20031013.sql.bz2 if the date is Oct 13th and the database name is "dbname".

Hope that helps a bit.
 
Old 10-14-2003, 06:24 AM   #3
wimpie_net
LQ Newbie
 
Registered: Jul 2003
Location: The Netherlands
Distribution: Debian 2.2.20-idepci
Posts: 8

Original Poster
Rep: Reputation: 0
Thnks dude.

This is very helpfull!!!
 
Old 10-16-2003, 02:44 PM   #4
wimpie_net
LQ Newbie
 
Registered: Jul 2003
Location: The Netherlands
Distribution: Debian 2.2.20-idepci
Posts: 8

Original Poster
Rep: Reputation: 0
It still doesn't work!
I think i'm going crazy!

I've tried to to run the mysqldump command but it doesn't work.
So I thought, maybe I don't have enough rights to run these commands under Knoppix.

When I put the disk back into my server and I boot it up I get the following menu:

Press Ctrl D to boot up the normal way or typ your root password for maintainence.
When I press Ctrl D the pc starts up again and I will come in the same menu.
When I type my root password I can access the database but cannot move it.
When I move it I get the response: Read Only filesystem.

Also I think it is logical I can't make an SQL dump because MYSQL isn't running.

Please, somebody help me!
 
Old 10-16-2003, 03:12 PM   #5
Raspis21
Member
 
Registered: Jun 2003
Posts: 33

Rep: Reputation: 15
Hi,

I don't know if mysql comes on knoppix, but you can check for it. Do a find for mysqld and execute it from the dir.

hope it helps
 
Old 10-16-2003, 04:03 PM   #6
wimpie_net
LQ Newbie
 
Registered: Jul 2003
Location: The Netherlands
Distribution: Debian 2.2.20-idepci
Posts: 8

Original Poster
Rep: Reputation: 0
Thnks for your help.
I've been able to restore the data of my MYSQL databases.
It has took some while but it worked out.

Thnks guys
 
  


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 - backup without connection muesli Linux - Software 1 07-01-2005 07:25 AM
Mysql backup? marghorp Linux - Software 11 02-24-2004 01:18 PM
simple MySQL backup Thulemanden Linux - Software 1 02-09-2004 03:03 PM
mysql backup ram_dhupkar Linux - General 13 09-09-2003 07:19 PM
mysql backup ram_dhupkar Linux - General 0 08-13-2003 03:46 AM


All times are GMT -5. The time now is 05:14 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration