MySQL 转储到目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6716650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:30:13  来源:igfitidea点击:

MySQL Dump to Directory

mysql

提问by gunwin

I'm currently trying to make a copy of a site to run locally, and i'm having some difficulty in downloading a dump of the mySQL database using PhpMyAdmin. (In that it doesn't work). I was wondering (and I suspect) if there is an sql command I can execute that would dump out the database to a location that I can download it via FTP.

我目前正在尝试制作一个站点的副本以在本地运行,但在使用 PhpMyAdmin 下载 mySQL 数据库的转储时遇到了一些困难。(因为它不起作用)。我想知道(并且我怀疑)是否有我可以执行的 sql 命令将数据库转储到我可以通过 FTP 下载它的位置。

I've found the following:

我发现了以下内容:

 mysqldump --opt --user=root --password password > /home/backup/db.sql

but the page says that this will only run via shell, and I don't have shel access to the server. Can anyone help?

但是页面上说这只能通过 shell 运行,我没有对服务器的 shell 访问权限。任何人都可以帮忙吗?

采纳答案by Gowtham Vakani

  1. Open the Command prompt from MySQL bin folder (Make sure you have Read/Write Access)

  2. Use the below mysqldump command

  1. 从 MySQL bin 文件夹打开命令提示符(确保您具有读/写访问权限)

  2. 使用下面的 mysqldump 命令

mysqldump -h [hostname] -u [username] -p [your database] > [your destination path][your filename.extn]

mysqldump -h [主机名] -u [用户名] -p [您的数据库] > [您的目标路径][您的文件名.extn]

Ex: mysqldump -h localhost -u root -p test_DB > D:\MySQL\Dumps\test_file.sql

例如:mysqldump -h localhost -u root -p test_DB > D:\MySQL\Dumps\test_file.sql

***WARNING : In case, if your custom path has any spaces in between, the above query will throw an error. Invalid Path Description

***警告:如果您的自定义路径之间有任何空格,则上述查询将引发错误。 无效的路径描述

To avoid Invalid Path Description, Give your path in double-quotes.

为避免无效的路径描述,请用双引号给出您的路径。

Ex : mysqldump -h localhost -u root -p test_DB > D:\MySQL\"Dumps from ABC"\test_file.sql

例如:mysqldump -h localhost -u root -p test_DB > D:\MySQL\"Dumps from ABC"\test_file.sql

回答by Camilla

mysqldump -u root -p -T/path/ database

回答by Asiimwe Apollo

PERFORM MySQL DATABASE DUMP:

执行 MySQL 数据库转储:

  1. Having registered mysql.exe in the Paths of Environment Variables(On Windows Os)
  2. Open windows console
  3. Type the following Query:

    mysqldump [Your database Name] -u root -p > C:/[Your Destination Directory ]/[ new Backup Database Name.sql ]

  4. You will be prompted for a database user password
  5. Enter Password:*******
  6. when the dump is over...the directory will go back to the current user session in Windows console
  1. 在环境变量的路径中注册了mysql.exe(在Windows操作系统上)
  2. 打开窗口控制台
  3. 输入以下查询:

    mysqldump [您的数据库名称] -u root -p > C:/[您的目标目录]/[ 新备份数据库名称.sql ]

  4. 系统将提示您输入数据库用户密码
  5. 输入密码:*******
  6. 当转储结束时...目录将返回到 Windows 控制台中的当前用户会话

For this to work well, replace all parameters in square braces "[ ]" with your own values without the square braces

为了使其正常工作,请将方括号“[]”中的所有参数替换为您自己的值,而无需方括号

回答by DevelRoot

What are you looking for is Sypex Dumper 2. It exports (backups) your database directly to disk, so you can download the backup via ftp. It is written on php, supports large databases and has a very nice interface.

您要找的是Sypex Dumper 2。它将您的数据库直接导出(备份)到磁盘,因此您可以通过 ftp 下载备份。它是用 php 编写的,支持大型数据库并且有一个非常漂亮的界面。

回答by Ramesh Y Manvi

Simple Three steps Export mysql DB

简单三步导出mysql数据库

**step1 :** run windows command prompt

**step2 :** make where yours wamp mysql stored directory ex E:\wamp\bin\mysql\mysql5.5.24\bin

**step 3 :**
E:\wamp\bin\mysql\mysql5.5.24\bin> mysqldump -u UserName -p PassWord dbname >c:\dbname.sql

回答by juandelossantos

You can go to the directory where you want store the file, then execute de mysqldump command.

你可以到你想存放文件的目录,然后执行de mysqldump命令。

~/Desktop$ sudo /Applications/XAMPP/xamppfiles/bin/mysqldump -u root  -p publicaciones > publicaciones.sql

PD. Use sudo to grant full permissions. PD. If you have your PATH setup, don`t need use the full route to your MySql commands.

PD。使用 sudo 授予完全权限。PD。如果您有 PATH 设置,则不需要使用 MySql 命令的完整路径。