Mysql remote Import and Export Database

Source: Internet
Author: User

Mysql remote Import and Export Database
First cd to D: \ wamp \ bin \ mysql \ mysql5.5.24 \ bin directory
(Personal Experience: win + r-> cmd-> cd e: \ wamp \ bin \ mysql \ mysql5.5.24 \ bin-> e: -> mysqldump -- default-character-set = gb2312-hlocalhost-uroot-p phpjin> d: \ test. SQL)
Import: (personal experience win + r-> cmd-> cd e: \ wamp \ bin \ mysql \ mysql5.5.24 \ bin-> e: -> mysql -- default-character-set = gb2312-hlocalhost-uroot-p phpjin <d: \ test. SQL)-Xiaomi

Remote export:

Mysqldump-P [port]-h [IP]-u [user]-p test> d: \ test. SQL

For example:

Mysqldump-P 3306-h 192.168.1.20.- u root-p test> d: \ test. SQL

Remote import:

Mysql-h [IP]-P [port]-u [user]-p test <c: \ test. SQL

For example:

Mysql-h 192.168.1.20.- P 3306-u root-p test <c: \ test. SQL

Appendix:
Remotely export the database: mysqldump-h [hosname]-u [user_name]-p [password] -- default-character-set = [char_set_name] [db_name]> [save_path]

Example: Then input: mysqldump-h119.12.12.11-umysql-pmysql123 -- default-character-set = utf8 aspchina -- skip-lock-tables> d: \ aspchina_net. SQL

Alternatively, you can: mysqldump-h119.12.11-u mysql> d: \ aspchina_net. SQL.

119.12.12.11 is the remote server IP address,-umysql mysql is the database username,-pmysql123 (no space interval) mysql123 is the user password, set = utf8 is the encoding format for exporting MYSQL, aspchina is the name of the database to be exported,> d: \ aspchina_net. SQL is the storage path for importing data to your local computer. You can freely name aspchina_net. SQL!

Remote Database Import:

If the MYSQL database is smaller than 2 MB, you can use mysqldump to import data. If the database size is 2 MB, it will not work because the PHPMYADMIN management tool provided by the Space Provider can only import data smaller than 2 MB, this depressing some webmasters who use MYSQL Databases!
Now we will teach you how to use mysqldump to import data larger than 2 MB.
1) in the lower left corner, choose Start> RUN> CMD to enter the doscommand line status.
2) D: \ Program Files \ MySQL Server 5.0 \ bin> the installation directory for your MYSQL installation, and \ bin is the directory in which the mysqldump management tool is located;
3) then enter mysql-h119.12.12.11-uaspchina-paspchina123456 aspchina <d: \ aspchina_net. SQL
Note: aspchina_net. SQL. If you do not have the permission to create a database, you cannot import it to the aspchina_net. SQL database. Otherwise, spchina_net. SQL can only be multiple tables. Otherwise, errors may occur. Remember this!

Appendix 2:
Using the mysql remote connection command to remotely import and export data is too convenient. It is not limited by the size of the phpmyadmin 2 MB file. You can also specify the data encoding to ensure that the imported data will not contain garbled characters, the command is as follows:
Mysqldump -- default-character-set = gb2312-hsf-0000000.00-uroot-pxxxxxx mydatabase> d: \ data. SQL

Here,-h is followed by an IP address,-u is followed by a user name,-p is followed by a password, mydatabase is the database name, and d: \ data. SQL is the exported data file. After execution, the database is backed up to the local device. You can use scheduled tasks to back up the database regularly.

The following command is similar to how to restore data:
Mysql -- default-character-set = gb2312-hsf-0000000.00-uroot-pxxxxxx mydatabase <d: \ data. SQL
After the execution, the database will be restored, and there will be no garbled characters.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.