ERROR 1046 (3D000) at line 22: No database selected Solution

Source: Internet
Author: User

During the mysql exercise, the table is backed up in advance because the table is to be deleted, but the following ERROR is always prompted during restoration: ERROR 1046 (3D000) at line 22: no database selected

The backup command is as follows:


[root@DB ~]# mysqldump  -uroot -p123456 addam test >/home/addam_test_bak.sql

Check whether a backup exists in/home


[root@DB ~]# ll /home-rw-r--r--  1 root      root      2132 Sep 11 23:54 addam_test_bak.sql

View the backup content. The content already exists.

Start the test. Use drop to delete the test table in the addam database. No problem is found. For future tests, I want to restore the test and start to report an error.

[root@DB ~]# mysql -uroot -p123456 

After carefully checking the 22 rows of the backup file, we found that the 22 rows were drop table if exists 'test'; of course, we couldn't find them, because my test is created in the addam library, the solution is to add a use addam before it;


21 USE addam;22 DROP TABLE IF EXISTS `test`;

Save and exit! Run the recovery command again to solve the problem!

So some people say that this row can be deleted? It cannot be dropped after testing ~

20 --21 /*!40101 SET @saved_cs_client     = @@character_set_client */;22 /*!40101 SET character_set_client = utf8 */;23 CREATE TABLE `test` (

After this row is deleted, the same error will still be reported, because the row 23rd still does not know which library to create, so it is better to directly add a use addam.

I still don't know if there are any other solutions, because some problems on the Internet are different from mine. I also met this problem for the first time. I don't know if it is the right or wrong solution, the problem is solved temporarily. If any Daniel has other solutions, please give me some advice. Thank you!

This article from the "wind don't Crane" blog, please be sure to keep this source http://addam.blog.51cto.com/5041993/1298235

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.