mysql 数据库备份还原_备份和还原MySQL数据库

mysql 数据库备份还原

MySQL databases can be backed up from the Command Prompt or from phpMyAdmin. It is a good idea to back up your MySQL data occasionally as a precautionary measure. It is also a good idea to create a back up before making any major changes, in case something goes wrong and you need to revert to the unmodified version. Database backups can also be used to transfer your database from one server to another if you change web hosts.

可以从命令提示符或phpMyAdmin备份MySQL数据库。 作为预防措施,偶尔备份您MySQL数据是一个好主意。 在进行任何重大更改之前创建备份也是一个好主意,以防万一出现问题并且您需要恢复到未修改的版本。 如果更改Web主机,数据库备份也可以用于将数据库从一台服务器转移到另一台服务器。

从命令提示符备份数据库 ( Back Up Database From the Command Prompt )

From a command prompt, you can back up an entire database using this line:

在命令提示符下,您可以使用以下行来备份整个数据库:

mysqldump -u user_name -p your_password database_name > File_name.sql

Example:Assume that:Username = bobbyjoePassword = happy234Database Name = BobsData

示例:假设:用户名= bobbyjoe密码= happy234数据库名称= BobsData

mysqldump -u bobbyjoe -p happy234 BobsData > BobBackup.sql

This backs up the database to a file called BobBackup.sql

这会将数据库备份到名为BobBackup.sql的文件中

从命令提示符还原数据库 ( Restore Database From the Command Prompt )

If you are moving your data to a new server or you have removed the old database completely, you can restore it using the code below. This only works when the database does not already exist:

如果要将数据移到新服务器上或已完全删除了旧数据库,则可以使用下面的代码将其还原。 这仅在数据库不存在时才起作用:

mysql - u user_name -p your_password database_name < file_name.sql

or using the previous example:

或使用前面的示例:

mysql - u bobbyjoe -p happy234 BobsData < BobBackup.sql

If your database already exists and you are just restoring it, try this line instead:

如果您的数据库已经存在并且您正在还原它,请尝试以下方法:

mysqlimport -u user_name -p your_password database_name file_name.sql

or using the previous example again:

或再次使用前面的示例:

mysqlimport -u bobbyjoe -p happy234 BobsData BobBackup.sql

从phpMyAdmin备份数据库 ( Back Up Database From phpMyAdmin )

backup mysql database with phpmyadmin
  1. Log in to phpMyAdmin.

    登录到phpMyAdmin。

  2. Click on your database name.

    单击您的数据库名称。
  3. Click on the tab labeled EXPORT.

    单击标签为导出的选项卡

  4. Select all the tables you want to back up (usually all of them). Default settings usually work, just make sure SQL is checked.

    选择要备份的所有表(通常是所有表)。 通常可以使用默认设置,只需确保选中了SQL

  5. Check the SAVE FILE AS box.

    选中另存为文件框。

  6. Click GO.

    单击执行

从phpMyAdmin还原数据库 ( Restore Database From phpMyAdmin )

restore mysql database from phpMyAdmin
  1. Login to phpMyAdmin.

    登录到phpMyAdmin

  2. Click on the tab labeled SQL.

    单击标签为SQL的选项卡。

  3. Unclick the Show query here again box

    取消单击在此处再次显示查询

  4. Choose your backup file

    选择您的备份文件
  5. Click GO

    点击GO

翻译自: https://www.thoughtco.com/backup-and-restore-mysql-databases-2693879

mysql 数据库备份还原

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值