Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to backup and transfer Files remotely in mysql Database

2025-02-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following is to understand how the mysql database to achieve backup and remote transfer files, I believe you will benefit a lot after reading, the text in the essence is not much, hope that the mysql database how to achieve backup and remote transfer of files this short content is what you want.

First, backup and import of database

1), backup of the database

1. Export the entire database

Mysqldump-u user name-p database name > exported file name

Example: mysqldump-u dbadmin-p myblog > / home/zhangy/blog/database_bak/myblog.sql

two。 Export a table

Mysqldump-u user name-p database name table name > exported file name

Example: mysqldump-u dbadmin-p myblog wp_users > / home/zhangy/blog/database_bak/blog_users.sql

3. Export a database structure

Mysqldump-u dbadmin-p-d-- add-drop-table myblog > / home/zhangy/blog/database_bak/blog_struc.sql

Note:-d has no data-add-drop-table adds a drop table before each create statement

4. Export a table structure in the database

Mysqldump-u dbadmin-p-d-- add-drop-table myblog wp_users > / home/zhangy/blog/database_bak/blog_users_struc.sql

Note:-d has no data-add-drop-table adds a drop table before each create statement

2), the import of database

1. The file backed up with mysqldump is a SQL script that can be poured directly, and there are two ways to import the data.

For example:

# / usr/local/mysql/bin/mysql-u root-p * myblog < / home/zhangy/blog/database_bak/myblog.sql

I used to use this method very little now, because it is easy to generate garbled code, because:

A, if you forget to set the export character set when exporting the database, there may be problems during import.

B, suppose you set the utf8 encoding when you export, but you change the current character set of your database to gb2312. It will be garbled again.

2, use the source statement

For example:

Mysql-u dbadmin-p

Use myblog

Set names utf8; # the character set here is the root of the character set of your database to be imported.

Source / home/zhangy/blog/database_bak/myblog.sql

Example

1. Copy from local to remote

Command format:

Scp local_file remote_username@remote_ip:remote_folder

Or

Scp local_file remote_username@remote_ip:remote_file

Or

Scp local_file remote_ip:remote_folder

Or

Scp local_file remote_ip:remote_file

After reading this article on how to back up and remotely transfer files in mysql database, many readers will want to know more about it. If you need more industry information, you can follow our industry information section.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 203

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report