Using mysqldump to import unsuccessful workarounds

Source: Internet
Author: User

Today encountered a wonderful problem, using mysqldump to export the database, the command is as follows: mysqldump-u root-p password database name >/tmp/mysql_data.sql, when using the import, the execution succeeds, displays

--MySQL dump 10.13 distrib 5.7.11, for Linux (x86_64)
--
--Host:localhost Database:apt
-- ------------------------------------------------------
--Server version 5.7.11

/*!40101 SET @[email protected] @CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected] @CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected] @COLLATION_CONNECTION */;
/*!40101 SET NAMES UTF8 */;
/*!40103 SET @[email protected] @TIME_ZONE */;
/*!40103 SET time_zone= ' +00:00 ' */;
/*!40014 SET @[email protected] @UNIQUE_CHECKS, unique_checks=0 */;
/*!40014 SET @[email protected] @FOREIGN_KEY_CHECKS, foreign_key_checks=0 */;
/*!40101 SET @[email protected] @SQL_MODE, sql_mode= ' no_auto_value_on_zero ' */;
/*!40111 SET @[email protected] @SQL_NOTES, sql_notes=0 */;
/*!40103 SET [email protected]_time_zone */;

/*!40101 SET[email protected]_sql_mode * *;
/*!40014 SET[email protected]_foreign_key_checks * *;
/*!40014 SET[email protected]_unique_checks * *;
/*!40101 SET[email protected]_character_set_client * *;
/*!40101 SET[email protected]_character_set_results * *;
/*!40101 SET[email protected]_collation_connection * *;
/*!40111 SET[email protected]_sql_notes * *;

--Dump completed on 2018-03-02 3:13:11

But there is no data in the database that goes into MySQL, and using the source import is sure to import the data.

According to the online saying: Remove/* * * * * * * * * All contents, re-import, the result is still not,

View data Discovery Some say that use-t path export using plain text, the results of each table exported to a file, not meet the requirements, carefully read the Help document, found to export the database to precede the--database parameter, the command is as follows: Mysqldump-u root-p password- -database Database name >/tmp/mysql_data.sql;

Import again, the result is successful.

Compare two files The file that was found to be exported without the database parameter begins with this:

--Host:localhost databases: database name
-- ------------------------------------------------------
--Server version 5.6.21

/*!40101 SET @[email protected] @CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected] @CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected] @COLLATION_CONNECTION */;
/*!40101 SET NAMES UTF8 */;
/*!40103 SET @[email protected] @TIME_ZONE */;
/*!40103 SET time_zone= ' +00:00 ' */;
/*!40014 SET @[email protected] @UNIQUE_CHECKS, unique_checks=0 */;
/*!40014 SET @[email protected] @FOREIGN_KEY_CHECKS, foreign_key_checks=0 */;
/*!40101 SET @[email protected] @SQL_MODE, sql_mode= ' no_auto_value_on_zero ' */;
/*!40111 SET @[email protected] @SQL_NOTES, sql_notes=0 */;

--
--Table structure for tables ' name '
--

The export file using the database parameter starts with this:

--MySQL dump 10.13 distrib 5.6.21, for Linux (x86_64)
--
--Host:localhost databases: database name
-- ------------------------------------------------------
--Server version 5.6.21

/*!40101 SET @[email protected] @CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected] @CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected] @COLLATION_CONNECTION */;
/*!40101 SET NAMES UTF8 */;
/*!40103 SET @[email protected] @TIME_ZONE */;
/*!40103 SET time_zone= ' +00:00 ' */;
/*!40014 SET @[email protected] @UNIQUE_CHECKS, unique_checks=0 */;
/*!40014 SET @[email protected] @FOREIGN_KEY_CHECKS, foreign_key_checks=0 */;
/*!40101 SET @[email protected] @SQL_MODE, sql_mode= ' no_auto_value_on_zero ' */;
/*!40111 SET @[email protected] @SQL_NOTES, sql_notes=0 */;

--
--Current database: ' Databases name '
--

CREATE database/*!32312 IF not exists*/' database name '/*!40100 DEFAULT CHARACTER SET UTF8 */;

Use ' database name ';

--
--Table structure for tables ' name '
--

The analysis is that when the database is not added, the data is not imported into the database, even if it is specified in the script when using mysqldump import.

Using mysqldump to import unsuccessful workarounds

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.