What are the basic concepts in Oracle architecture?

Source: Internet
Author: User
Tags mysql backup

The following articles mainly describe how to back up MySQL database-putty in Linux, in addition, in the Linux operating system, MySQL database backup-putty's actual operations are worth our attention. The following is the detailed content of the article.

Abstract: This article introduces the Linux MySQL database backup-putty
Tags: Linux SQL database MySQL backup
Oracle helps you gain an accurate insight into each logistics Link

Prerequisites: You have the ssh logon permission.

Work steps:

Download the software putty and set the ssh Login Option

After logging in, go to your home page Directory * (accessible through ftp)

Execute the MySQLdump command to execute database backup, and the MySQLrestore command to restore the database.

Format:

PXXXXXXX @ kundenserver :~ > MySQLdump -hdbXX.puretec.de-upXXXXXXX-p ******** dbXXXXXXX> dbXXXXXXXX. SQL

PXXXXXXX @ kundenserver :~ > MySQL -hdbXX.puretec.de-upXXXXXXX-p ********* dbXXXXXXX <dbXXXXXXXX. SQL

After MySQLdump is executed, a MySQL database backup file (equivalent to the database size) is generated in the current directory)

You can download the backup database file package through ftp.

Restoring the database is opposite to the above two

You can also write a php script to complete the above operations:

MySQL database backup file

 
 
  1. Include "../config. php ";
  2. MySQL_CONNECT ($ dbhost, $ dbuser, $ dbpw) or die ("<H3> database inaccessible </H3> ");
  3. MySQL_SELECT_DB ($ dbname) or die ("<H3> database not established </H3> ");
  4. $ Path = getenv ('document _ root'). "/DB_backup ";
  5. $ Result = MySQL_QUERY ("show tables ");
  6. $ Numrow = MySQL_NUM_ROWS ($ result );
  7. For ($ I = 0; $ I <$ numrow; $ I ++ ){
  8. $ Table = MySQL_RESULT ($ result, $ I );
  9. Echo "$ table ...";
  10. System (sprintf ("MySQLdump -- opt-h $ dbhost-u $ dbuser-p $ dbpw $ dbname $ table | gzip> % s/$table. SQL .gz", $ path ));
  11. Echo "DONE \ n ";
  12. }
  13. MySQL_CLOSE ();

Restore Files

 
 
  1. include "../config.php";  
  2. system(sprintf(  
  3. 'gunzip -c %s/dump.sql.gz | MySQL -h %s -u %s -p%s %s',  
  4. getenv('DOCUMENT_ROOT'),  
  5. $dbhost,  
  6. $dbuser,  
  7. $dbpw,  
  8. $dbname  
  9. ));  
  10. echo '+DONE'; 

The above content is an introduction to the MySQL database backup-putty in Linux. I hope you will get something.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.