MySQL Database Usage Summary error 1146 (42S02)

Source: Internet
Author: User

transferred from: http://jazka.blog.51cto.com/809003/330418/In the process of using MySQL database, encountered error 1146 (42S02): Table doesn ' t exist, after two days, finally solved the problem. The cause of the error is different, and the corresponding solution is different. This is only a description of my situation. May be written in a disorderly, I hope you look slowly, the following is my entire accessory error to solve the problem of the whole process, to help you better understand the relevant knowledge. Let's talk about the situation where the error occurred. I am the other people's database directory directly copied from the Data folder, there are three databases MySQL, test and Backupctrl, mainly want to Backupctrl database, remember not backup, is a copy, And Backupctrl is using InnoDB as the storage engine, and these two aspects combine to cause 1146 of this error. because you want to use InnoDB as the storage engine, you need to modify the My.ini file accordingly. In the My.ini file, you can find the relevant settings for InnoDB, but it is commented out. Since the mysql5.1 version, InnoDB is not set as the default. The Skip-innodb is commented out first, and then the relevant parameters of the correct innodb need to be set. with the InnoDB storage engine, there are some files under the Data folder: Ib_logfile0, Ib_logfile1, and Ibdata1, and another is the numerous. frm files under the database name. A brief introduction to these documents is given first. Ib_logfile0 and Ib_logfile1 are some log files about the database;The . frm file is a structural description file for many tables in the database;ibdata1 files when the real data of the database is stored. After you copy the Data folder of someone else, you run the command under the Bin folder in the MySQL directory:MySQL--consoleat this point, you will find a lot of error hints that the command is to test the environment. If you ignore these errors, enter the database, use Show tables, command to find the database table exists, but perform a select and so on will appear 1146:table doesn ' t exist this error. In fact, this is caused by the error of ibdata1 file, this should be found in the log Files Ib_logfile0 and ib_logfile1 (this I did not verify), so the ibdata1 file deleted, execute the command again, found no prompt error, However, after entering the database, the operation will still cause 1146 of this error. Later carefully, also, you said you put the Ibdata1 file deleted, equivalent to the real data of the database deleted, then you will ask why the database table still exist, can see (in fact, I thought so), Because the description of the database table structure is in the numerous files of. frm, it is possible to pass the show tables; look. then the next question comes out: Ibdata1 file is copied from someone else, why in there can use, to my side can't use it? This is the core problem, because MySQL uses buffering to write data to the Ibdata1 file , which is why the Fflush () function exists. So when someone else's MySQL is running, you copy the Data folder, that is, copying the ibdata1 will certainly result in an error in the file (the exact cause of the error is not in-depth learning). know the above problem, the solution is much simpler, hehe. First, stop someone else's MySQL service (this goes without saying, in my top two posts, you can refer to it), and then copy the Data folder and replace it with your corresponding directory . In this way, you can follow the method described in my blog http://jazka.blog.51cto.com/809003/329423 to operate the database. find a solution on the internet, found that there are many people have this problem, and according to stop the service and then copy the way still not (I just started not, but later on, strange, do not know why). So here's another way. First in your own MySQL, set up a database you are about to copy (the database name is the same, there is no need to build a table), and then copy all the. frm files into your database folder, this time again into MySQL, with show tables to see if the table has been built up. Then stop your own MySQL service, found in the data file already have Ib_logfile0, Ib_logfile1 and ibdata1 three files (free install version is not after the decompression), and then stop the other people's MySQL service, Just copy the Ibdata1 file over and overwrite it, and finally start your own MySQL service to get the database up and running.

MySQL Database Usage Summary error 1146 (42S02)

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.