如何在远程服务器上备份 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

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

How to backup MySQL database on a remote server?

mysqldatabasebackupremote-serverdatabase-restore

提问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

If the server admits PHP, you can upload and try Adminer. I like it as a PHPMyAdmin replacer, and you can create backups with it!

如果服务器承认 PHP,您可以上传并尝试Adminer。我喜欢它作为 PHPMyAdmin 的替代品,你可以用它创建备份!

回答by Kurt Van den Branden

mysqldump.exelocks 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 usernameinto your own username, change ipaddressinto the remote ip address, and myDBto the actual database you want to backup. This will prompt you for your password. Once provided, the dump starts.

更改username为自己的用户名,更改ipaddress到远程的IP地址,并myDB以实际的数据库要备份。这将提示您输入密码。一旦提供,转储开始。