如何在远程服务器上备份 MySQL 数据库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19552150/
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
How to backup MySQL database on a remote server?
提问by john smith
I have a MySQL database existing on a remote server. I only have sqlconnection privilege. I don't have FTP access to the server, and I need to do a complete dump of the database. I have tried mysqldump
, but the issue is that it is creating the output on the server and as I don't have FTP I can not get the output from the server.
我在远程服务器上有一个 MySQL 数据库。我只有sql连接权限。我没有对服务器的 FTP 访问权限,我需要对数据库进行完整的转储。我试过mysqldump
,但问题是它正在服务器上创建输出,因为我没有 FTP,所以无法从服务器获取输出。
How can I do a clean backup and get the dump in my local machine(of course, the backup should be restored in my local machine)?
我怎样才能做一个干净的备份并在我的本地机器上获得转储(当然,备份应该在我的本地机器上恢复)?
回答by Barmar
You can specify the server name as an option to mysqldump
:
您可以将服务器名称指定为以下选项mysqldump
:
mysqldump --host servername dbname > dbname.sql
回答by Henry
mysqldump --host hostaddress -P portnumber -u username -ppassword dbname > dbname.sql
Normally the remote port of MySQL is 3306. Here is an example:
通常 MySQL 的远程端口是 3306。下面是一个例子:
mysqldump --host 192.168.1.15 -P 3306 -u dev -pmjQ9Y mydb > mydb.sql
回答by user2849406
You can use the MySQL workbench http://www.mysql.com/products/workbench/, which can backup directly to a local folder through a user-friendly interface
您可以使用 MySQL 工作台http://www.mysql.com/products/workbench/,它可以通过用户友好的界面直接备份到本地文件夹
回答by Sathish D
I use SQLyog for this where we can connect to the remote server and take a back up with this tool.
我为此使用 SQLyog,我们可以在其中连接到远程服务器并使用此工具进行备份。
回答by combuilder
回答by Kurt Van den Branden
mysqldump.exe
locks tables by default, so other SQL actions are not possible during a dump. Without locking any tables, use the following syntax to backup a complete remote db and dump everything on your local machine:
mysqldump.exe
默认情况下锁定表,因此在转储期间无法执行其他 SQL 操作。在不锁定任何表的情况下,使用以下语法备份一个完整的远程数据库并将所有内容转储到本地机器上:
mysqldump -u username -p --single-transaction --quick --lock-tables=false -h ipaddress myDB > backup.sql
Change username
into your own username, change ipaddress
into the remote ip address, and myDB
to the actual database you want to backup. This will prompt you for your password. Once provided, the dump starts.
更改username
为自己的用户名,更改ipaddress
到远程的IP地址,并myDB
以实际的数据库要备份。这将提示您输入密码。一旦提供,转储开始。