Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved.

Similar presentations


Presentation on theme: "Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved."— Presentation transcript:

1 Kirkwood Center for Continuing Education By Fred McClurg, frmcclurg@gmail.com Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved.

2 Chapter Nine Database Administration http://webcert.kirkwood.edu/~fmcclurg/cour ses/php/slides/chapter09f.administration.ppt

3 Backing Up MySQL Data (Copy Method) Database Copy Procedure 1.Shut down the MySQL service 2.Copy data files to backup location http://localhost/phpmyadmin/ http://localhost/phpmyadmin/ On Windows: C:\Program Files\MySQL\MySQL Server 5.1\data\database_name C:\xampp\mysql\data On Unix: /var/lib/mysql

4 Restoring MySQL Data (Copy Method) Restoring Database Procedure: 1.All files must be replaced in the same directory from which they were backed up. 2.Restart database service

5 Copy Method Advantages/Disadvantages Advantages: 1.Fast 2.Easy Disadvantages 1.Not recommended for moving or upgrading databases 2.All or nothing data restoration

6 mysqldump Backup (Preferred Method) Creating mysqldump Backups Description: The SQL commands used to create the tables and the data can be redirected to a file. That file can then be used to rebuild the database. Syntax: mysqldump –u user –p db_name mysqldump –u user –p db_name table_name

7 Creating mysqldump Backups Examples: Backup one database: mysqldump –u root –p notedb > notedb_backup.sql Backup one database table: mysqldump –u root –p notedb notecard > notecard_backup.sql

8 Creating mysqldump Backup (cont.) Examples: Backup all databases: mysqldump –u root –p –-all-databases > full_backup.sql Backup Schema w/o Data: mysqldump –u root –p -–not-data > schema_only.sql Backup Data Only w/o Schema: mysqldump –u root –p -–no-create-info > data_only.sql

9 mysqldump Advantages/Disadvantages Advantages: 1.SQL generated can be used to migrate database to a new version or architecture 2.Can be used for a partial backup/restore 3.Scriptable Disadvantages 1.Not point and click Note: Similar capability is available via phpmyadmin

10 Restoring mysqldump Backups Restore databases created with --all-databases : mysql –u root –p < full_backup.sql Restore only one database: mysql –u root –p -D notedb < notedb_backup.sql

11 Working with CSV Data in MySQL Exporting Database in CSV Format Create separate files for each table in database: mysqldump –u root –p --no-create-info --tab=csvDir --fields-terminated-by=',' notedb Importing CSV into Database: mysqlimport –u root –p --fields-terminated-by=',' notedb notecard.csv Note: The filename prefix determines the table name

12 For more MySQL Information General Documentation: http://dev.mysql.com/doc/ MySQL 5.1 Reference Manual: http://dev.mysql.com/doc/refman/5.1/en/

13 to be continued... http://webcert.kirkwood.edu/~fmccl urg/courses/php/slides/chapter10.ppt


Download ppt "Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved."

Similar presentations


Ads by Google