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