You are here: Re: [PHP] Copy mySQL database... « PHP « IT news, forums, messages
Re: [PHP] Copy mySQL database...

Posted by Steve Buehler on 10/01/05 11:07

At 08:52 AM 2/3/2005, you wrote:

>I just need to make a duplicate copy of a mySQL database (I have to
>reinstall some web software and I am afraid it will overwrite the existing
>database, so i would like to make a backup of it)...
>
>Any classes, scripts, etc out there to do this?

This is more of a question for the mysql mailing list unless you
MUST use PHP to do it. In that case, I would suggest phpmyadmin....just my
preference.
Besides mysqldump and a few other things. You can also just copy
the directory to a new directory if you have root access. Just make sure
that you keep the same permissions.
cd /var/lib/mysql (assuming this is where your databases are)
mkdir backuptest (this would be the name of the new directory)
cp -pr test/* backuptest (this would copy the database "test" to the new
directory you just created)

It would be a good idea to stop the database first then do a myisamchk.
myisamchk --silent --force --fast --update-state -O key_buffer=64M \
-O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M \
/var/lib/mysql/*/*.MYI

Those "\" backslash characters are to tell you that the command is all one
line (without the backslashes).
After you have done all of this, then restart the database. If
you are moving to a new machine with the data, then you can either use the
mysqldump of the database or tar/gzip up the directory before you restart
mysqld and untar/ungzip it onto the new machine. I am not going to
guarantee that the last method will always work for you, but I have done it
in the past from linux to linux, linux to windows and windows to linux with
no problem. If you are moving it to a new server, you will need to make
sure to setup the access permissions again in the mysql database. Also,
you can use the backuptest database by doing the same thing if you are not
root and root doesn't have full privileges on every database. Strange, but
I have seen a setup like that.

Steve

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация