Download Database Administration

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Microsoft Access wikipedia , lookup

IMDb wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Oracle Database wikipedia , lookup

Concurrency control wikipedia , lookup

Ingres (database) wikipedia , lookup

Functional Database Model wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Database wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

SQL wikipedia , lookup

Open Database Connectivity wikipedia , lookup

PL/SQL wikipedia , lookup

ContactPoint wikipedia , lookup

Relational model wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Transcript
Introduction to
PHP and MySQL
Kirkwood Center for
Continuing Education
By Fred McClurg, [email protected]
Copyright © 2010 All Rights Reserved.
Chapter Nine
Database Administration
http://webcert.kirkwood.edu/~fmcclurg/cour
ses/php/slides/chapter09f.administration.ppt
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/
On Windows:
C:\Program Files\MySQL\MySQL
Server 5.1\data\database_name
C:\xampp\mysql\data
On Unix:
/var/lib/mysql
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
Copy Method Advantages/Disadvantages
Advantages:
1. Fast
2. Easy
Disadvantages
1. Not recommended for moving or
upgrading databases
2. All or nothing data restoration
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
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
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
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
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
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
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/
to be continued ...
http://webcert.kirkwood.edu/~fmccl
urg/courses/php/slides/chapter10.ppt