View previous topic :: View next topic |
Author |
Message |
Johnyp Guru
Joined: 23 Mar 2005 Posts: 301
|
Posted: Fri Jun 03, 2005 8:54 pm Post subject: MySQL - where are the actual databases (files) are located ? |
|
|
Hey all
I'm new to databases and i have couple of sites running using MySQL ... but i have no idea where the actual database files (ones holding all my data) are located? I want to know where they are so i can back them up...
Thanks all _________________ Gentoo Unanswered Questions- Give it a try! |
|
Back to top |
|
|
overkll Veteran
Joined: 21 Sep 2004 Posts: 1249 Location: Austin, Texas
|
Posted: Fri Jun 03, 2005 9:10 pm Post subject: |
|
|
Check /var/lib/mysql/
If you haven't already, emerge slocate and learn how to use it. Very handy indeed! |
|
Back to top |
|
|
dejima Tux's lil' helper
Joined: 16 Jul 2004 Posts: 130 Location: Greece
|
Posted: Sat Jun 04, 2005 12:02 am Post subject: |
|
|
To backup your databases use also mysqldump.
Using this tool you could specify whether you want all of your databases backed up or just one of them. |
|
Back to top |
|
|
Stolz Moderator
Joined: 19 Oct 2003 Posts: 3028 Location: Hong Kong
|
Posted: Sat Jun 04, 2005 5:55 am Post subject: |
|
|
this is the script I use to backup my DB:
Code: | #!/bin/sh
DATUM=`date '+%Y-%m-%d'`
DIR='/home/stolz/DBbackup'
FILE='backup.sql'
mysqldump -u stolz -p topsecret -hlocalhost --opt mydatabase > ${DIR}/${FILE}
gzip -9 --best ${DIR}/${FILE}
chmod 700 ${DIR}/${FILE}.gz
mv ${DIR}/${FILE}.gz ${DIR}/${DATUM}-${FILE}.gz |
May be there is a more elegant way, but it do the job for me
Just remember to add a cron job for run it periodically.
Hope it helps. |
|
Back to top |
|
|
dejima Tux's lil' helper
Joined: 16 Jul 2004 Posts: 130 Location: Greece
|
Posted: Sat Jun 04, 2005 8:51 pm Post subject: |
|
|
I use a script like Stolz's.
The only difference is that I don't rotate my backup files through the script.
I use logrotate for this reason.
Using logrotate gives you the option to compress,change ownership and rights of the file you are rotating.You could specify when you want your file to be rotated(weekly,monthly....) |
|
Back to top |
|
|
|