GameStudioD
09-07-2004, 12:50 PM
I am a competent programmer, but I am new to server side scripting (PHP) and web stuff. I am wondering how to archive a mysql database to file. I am guessing the mysql db isnt just a file (like MS Access) that can just be copied. So is there a php script out there or a simple way to do this?
IF you have command line access just use "mysqldump" which will create a raw sql file
Rus
Angelo
09-07-2004, 03:37 PM
You can backup using PhpMyadmin's Export function. If you have physical access to the machine, you can just take the data files *.MY and *.FRM. Whenever needed again on another machine, just copy them on to the new machine's data dir.
You can backup using mysqldump
or you can tar the database directory in the mysql data path.
Cheers,
Matt
tanfwc
09-08-2004, 12:27 PM
Originally posted by jvds
IF you have command line access just use "mysqldump" which will create a raw sql file
Rus
How to restore a raw mysqldump then?
tuxguru
09-08-2004, 02:15 PM
Originally posted by tanfwc
How to restore a raw mysqldump then?
mysql -u username -p database_name < dumpfile.sql
It'll ask you for the database password for the user. The database should be created prior to restoring the dump.
mouldy_punk
09-08-2004, 02:41 PM
Just to expand on this question as I'm curious :p
How would one go abouts making a php script that will dump your database? For example, when I click a link in my admin backend it will ask me to save the dump?
tuxguru
09-08-2004, 02:52 PM
An easy way would be to execute the mysqldump binary using an exec family function.
tuxguru
09-08-2004, 02:58 PM
If you want to do it the hard way, you may get all the details from the database using mysql functions (such as mysql_list_tables, mysql_tablename, mysql_list_fields, mysql_field_name, mysql_field_type, etc.)and queries and then write a dump file from the details.
Cole2026
09-08-2004, 04:51 PM
I run mysql on my computer, and its really not that hard, command line usage is simple as long as you look 5 min & go over the commands.:)