Wątki

[ Pobierz całość w formacie PDF ]
.qxp 12/17/07 8:32 PM Page 288288 Backing Up Your DatabaseBacking up a database with phpMyAdminYou can back up your database from phpMyAdmin.phpMyAdmin providesan export feature that exports the database structure and/or data to a sepa-rate file.You can use this file to restore your data on the current computeror to re-create your database on a different computer.To back up your database, follow these steps:1.From the phpMyAdmin main page, select a database.Select a database from the Database drop-down list.The Database page for the selected database appears, as shown inFigure 2-3.2.Click the Export tab at the top of the page.The View Dump page appears, shown in Figure 2-4.This page allows youto specify the options for the data you re exporting.3.In the Export section on the left side of the main panel, select thetables you want to export from the list box.4.Select the SQL radio button.The SQL radio button is close to the bottom of the section.Figure 2-3:The phpMyAdminDatabasepage. 17_167779 bk03ch02.qxp 12/17/07 8:32 PM Page 289289Backing Up Your DatabaseFigure 2-4:The phpMyAdminView Dumppage.Book IIIChapter 25.Locate the SQL Options section in the main panel.This section contains some options at the top and two subsectionslabeled Structure and Data.Some options are selected by default.Don tchange the default selections at the top of the SQL Options section.6.If the Structure check box and the four check boxes at the top of theStructure section aren t checked, select them.7.If the Data checkbox and the Use Hexadecimal for Binary Fields checkbox aren t checked, select them.Figure 2-5 shows the checked boxes.8.Scroll down to the Save as File section and select the Save as Filecheck box.9.Change the filename template, if you want.The default template is __DB__.When you save the file, this name isreplaced with the database name.You can add to this template name byusing text or some special characters.For example, you can use thetemplate __DB__-%Y%m%d.The special characters represent a date.This template creates the filename databasename-20071015.You canuse any special characters recognized by the PHP strtotimefunction,as described in Book II, Chapter 1.AdministeringMySQL 17_167779 bk03ch02.qxp 12/17/07 8:32 PM Page 290290 Restoring Your DataSelect the Remember Template check box, and phpMyAdmin displaysthe new filename template every time you save a data file.10.Set the compression option to None.11.Click the Go button.Your browser s Save File window opens.The name of the file being savedappears in the window.12.Select the option to save your file to disk and click OK.The file is saved wherever your browser saves files.If you ve set yourbrowser to ask you where to save files, a window opens, and you cannavigate to the directory in which you want to save the file.You can use the Export feature to save other types of files, such as XML files.If you want to save another type of file, read the phpMyAdmin documenta-tion, available from a link on the phpMyAdmin main page.Restoring Your DataAt some point, one of your database tables might become damaged andunusable.It s unusual, but it happens.For instance, a hardware problem oran unexpected computer shutdown can cause corrupted tables.Sometimes,an anomaly in the data that confuses MySQL can cause corrupt tables.Insome cases, a corrupt table can cause your MySQL server to shut down.Here s a typical error message that signals a corrupted table:Incorrect key file for table:  tablename.You can replace the corrupted table(s) with the data stored in a backup copy.However, in some cases, the database might be lost completely.For instance,if the computer on which your database resides breaks down and can t befixed, your current database is lost  but your data isn t gone forever.Youcan replace the broken computer with a new computer and restore yourdatabase from a backup copy.You can replace your current database table(s) with the database you vestored in a backup copy.The backup copy contains a snapshot of the data asit was when the copy was made.Of course, you don t get any of the changesto the database since the backup copy was made; you have to re-createthose changes manually.Again, if you access MySQL through an IT department or through a Web hostingcompany, you need to ask the MySQL administrator to restore your databasefrom a backup.If you re the MySQL administrator, you can restore it yourself. 17_167779 bk03ch02.qxp 12/17/07 8:32 PM Page 291291Restoring Your DataAs we describe in Chapter 1 of this minibook, you build a database by creatingthe database and then adding tables to the database [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • mikr.xlx.pl
  • Powered by MyScript