简体   繁体   中英

How to backup MySQL database on a remote server?

I have a MySQL database existing on a remote server. I only have connection 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.

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)?

您可以将服务器名称指定为mysqldump的选项:

mysqldump --host servername dbname > dbname.sql
mysqldump --host hostaddress -P portnumber -u username -ppassword dbname > dbname.sql

通常MySQL的远程端口是3306.这是一个例子:

mysqldump --host 192.168.1.15 -P 3306 -u dev -pmjQ9Y mydb > mydb.sql

您可以使用MySQL工作台http://www.mysql.com/products/workbench/ ,它可以通过用户友好的界面直接备份到本地文件夹

我使用SQLyog来连接远程服务器并使用此工具进行备份。

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!

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 -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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM