Home Database Mysql Tutorial linux下拷贝MySql数据库文件备份数据库

linux下拷贝MySql数据库文件备份数据库

Jun 07, 2016 pm 05:41 PM
sql sql statement database backup

大致上MySql数据库备份可以采用两种方式:一种就是直接导出sql语句或者易于导入的其他格式的sql存储文件,使用sql语句或者一些可视化客户端导出,这种方法非常简

     大致上MySql数据库备份可以采用两种方式:一种就是直接导出sql语句或者易于导入的其他格式的sql存储文件,香港服务器租用,使用sql语句或者一些可视化客户端导出,这种方法非常简单,无需赘述;另一种方法就是拷贝出数据库文件,再将数据库文件转换成sql文件,虚拟主机,香港虚拟主机,这篇文章就介绍一下这种方法。

    ①查找数据库文件存放位置,MySql文件的后缀有三种形式*.MYD、*.MYI、*.frm;

  •    

        ②进入数据库存储文件目录;

  • cd /opt/lanmp/mysql-5.1.63/win/data/ 
  •     ③使用copy命令把所有数据拷出去;

  • copy mysql /home 
  •     ④此时只需将这些数据库文件转换成sql文件,这也是这篇文章里我要讲的重点,如果需要的时候再将sql文件用命令导入即可;

        ⑤新建一个数据库命名为mysqlbak,将刚才拷出来的文件夹拷入新数据库的data文件夹;

  • cd /home/mysql 
  • copy * /www/wdlinux/mysql-5.1.63/var/mysqlbak/ 
  •     ⑥此时就已经可以看到新数据库mysqlbak里的数据了,跟原数据库mysql里的数据是一样的;

        ⑦使用命令导出数据库文件即可。

  • mysqldump -uroot -p mysqlbak > /home/mysql.sql 
  •     ⑧这home文件夹下的文件mysql.sql文件就是易导入的数据库文件。需要注意的是所有的操作都必须在操作系统下用命令完成,而不提倡使用工具。因为在实际操作过程中,我们经常会遇到数据库里的数据库文件版本和数据库版本不一致,或者新旧数据库版本不一致的问题,再或者数据服务器版本与客户端工具不兼容等意想不到的问题,如果是这种情况,使用工具导出一般会报“1577:Cannot proceed because system tables used by Event Scheduler were found damaged at server start”的错误。说到这里,其实本文也提供了一种打开mysql数据库文件的方法,如果现在只有一堆*.MYD、*.MYI、*.frm文件,执行步骤⑤到步骤⑧即可。

    本文出自 “虹猫仗剑走天涯” 博客,谢绝转载!

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Hot Topics

    Java Tutorial
    1664
    14
    PHP Tutorial
    1266
    29
    C# Tutorial
    1239
    24
    How to create tables with sql server using sql statement How to create tables with sql server using sql statement Apr 09, 2025 pm 03:48 PM

    How to create tables using SQL statements in SQL Server: Open SQL Server Management Studio and connect to the database server. Select the database to create the table. Enter the CREATE TABLE statement to specify the table name, column name, data type, and constraints. Click the Execute button to create the table.

    How to write a tutorial on how to connect three tables in SQL statements How to write a tutorial on how to connect three tables in SQL statements Apr 09, 2025 pm 02:03 PM

    This article introduces a detailed tutorial on joining three tables using SQL statements to guide readers step by step how to effectively correlate data in different tables. With examples and detailed syntax explanations, this article will help you master the joining techniques of tables in SQL, so that you can efficiently retrieve associated information from the database.

    How to judge SQL injection How to judge SQL injection Apr 09, 2025 pm 04:18 PM

    Methods to judge SQL injection include: detecting suspicious input, viewing original SQL statements, using detection tools, viewing database logs, and performing penetration testing. After the injection is detected, take measures to patch vulnerabilities, verify patches, monitor regularly, and improve developer awareness.

    How to create Mysql database using phpMyadmin How to create Mysql database using phpMyadmin Apr 10, 2025 pm 10:48 PM

    phpMyAdmin can be used to create databases in PHP projects. The specific steps are as follows: Log in to phpMyAdmin and click the "New" button. Enter the name of the database you want to create, and note that it complies with the MySQL naming rules. Set character sets, such as UTF-8, to avoid garbled problems.

    How to use SQL statement insert How to use SQL statement insert Apr 09, 2025 pm 06:15 PM

    The SQL INSERT statement is used to insert data into a table. The steps include: specify the target table to list the columns to be inserted. Specify the value to be inserted (the order of values ​​must correspond to the column name)

    How to check SQL statements How to check SQL statements Apr 09, 2025 pm 04:36 PM

    The methods to check SQL statements are: Syntax checking: Use the SQL editor or IDE. Logical check: Verify table name, column name, condition, and data type. Performance Check: Use EXPLAIN or ANALYZE to check indexes and optimize queries. Other checks: Check variables, permissions, and test queries.

    How to add columns in PostgreSQL? How to add columns in PostgreSQL? Apr 09, 2025 pm 12:36 PM

    PostgreSQL The method to add columns is to use the ALTER TABLE command and consider the following details: Data type: Select the type that is suitable for the new column to store data, such as INT or VARCHAR. Default: Specify the default value of the new column through the DEFAULT keyword, avoiding the value of NULL. Constraints: Add NOT NULL, UNIQUE, or CHECK constraints as needed. Concurrent operations: Use transactions or other concurrency control mechanisms to handle lock conflicts when adding columns.

    phpMyAdmin comprehensive use guide phpMyAdmin comprehensive use guide Apr 10, 2025 pm 10:42 PM

    phpMyAdmin is not just a database management tool, it can give you a deep understanding of MySQL and improve programming skills. Core functions include CRUD and SQL query execution, and it is crucial to understand the principles of SQL statements. Advanced tips include exporting/importing data and permission management, requiring a deep security understanding. Potential issues include SQL injection, and the solution is parameterized queries and backups. Performance optimization involves SQL statement optimization and index usage. Best practices emphasize code specifications, security practices, and regular backups.

    See all articles