Home Database Mysql Tutorial MySQL关于InnoDB的几个错误_MySQL

MySQL关于InnoDB的几个错误_MySQL

Jun 01, 2016 pm 01:17 PM
mysql server Ali Cloud

阿里云服务器上装有MySQL 5.6,这几天MySQL服务经常死掉,启动MySQL服务(service mysql start),却报如下错误

Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).

简单的去搜索一下关于此错误的解决方法,找到一个说删除InnoDB表的日志文件即可,于是就尝试了一下(删除操作首先别忘了备份)

不知道mysql数据存放位置的可以这样子查看,找到my.cnf,里面的datadir=/var/lib/mysql既是了

cat /etc/my.cnf 找到mysql数据存放位置

来到这里面有三个文件ibdata1,ib_logfile0,ib_logfile1

其中ibdata1是InnoDB表的共享表空间,切忌不可以删除这个文件,部分InnoDB表的数据就在里面呢

ib_logfile0,ib_logfile1,这两个文件不同配置下名字会不同,是InnoDB表的日志文件(别忘记了InnoDB表示事务安全的,当数据库奔溃时,重启数据库服务,会根据这些日志文件重做一些事务

删除了这两个日志文件,然后启动mysql(service mysql start)这次启动成功了!

--------------------------------------------------------------------------------------------------------

可是过了不久,真的不久,才十几分钟,数据库又挂了,启动数据库(service mysql start),又报下面这个错误

Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).

然后再次删除日志文件,再启动,可以了,再过了不久……又挂了,所以明白,问题不出于这里

这些问题,每个人出错的都不一样,网上别人的出错原因也许和你不一样呢,要不人家可以解决,你怎么就不可以解决,故去查看msyql错误记录文件自己瞧个明白

msyql错误记录文件不知道在哪里,可以这样子来找:同样查看my.cnf文件,其中mysqld-safe下的log-error就是mysql错误日志

[mysqld_safe]
log-error=/var/log/mysqld.log

打开它看看,发现一堆错误,用这个命令简单看一下出错重点

cat /var/log/mysqld.log | grep 'ERROR' | less

发现了服务启动时,为何会跑错了

2013-08-04 13:48:22 760 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace em/temp uses space ID: 2 at filepath: ./em/temp.ibd. Cannot open tablespace mysql/innodb_index_stats which uses space ID: 2 at filepath: ./mysql/innodb_index_stats.ibd 

打开表空间出错!!出这个错的原因是以前有次操作把ibdata1给删除掉了!(ibdata1文件刚才说了,共享表空间!!删除掉了后mysql虽然会重新生成,但是已经损坏了所有的InnoDB数据库了。ps:为什么会删除掉这个文件,我也不知道是什么时候删除了,是通过history看到的)

找到原因了,但是ibdata1这个文件没有备份,恢复不了,还在我这个服务上的数据库都是测试数据,可以drop掉重新导入以前备份的版本,故drop掉损坏的数据库,在mysql命令中是drop不掉的,只能在文件系统里直接删除其文件(第一步已经知道了数据存储位置了,直接删(ps记得先备份))

然后再重建了数据库,导入数据,重启mysql,正常启动,过了一天还没有挂掉!修复成功!第二天再去看一下mysql错误日志,又有了新发现

--------------------------------------------------------------------------------------------------------------

tail -n 200 /var/log/mysqld.log

 

文件里都在报这样的错误

Error: Table "mysql"."innodb_table_stats" not found.

2013-04-02 09:07:35 7fc53f5e4700 InnoDB: Recalculation of persistent statistics requested for table "mydatabase"."mytable" but the required persistent statistics storage is not present or is corrupted. Using transient stats instead.

但是目前有没察觉到对项目和数据库使用的明显影响,但是还要解决的,这篇博客说的很明白,果断推荐

http://hi.baidu.com/life_to_you/item/d35894c0058a993098b498ee

最后,都没发现什么问题了。MySQL遇到什么问题,第一下还是看下mysql的错误日志比较好,里面记录的一清二楚,逐个排除就好啦

 

 

 

 

 

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1242
24
MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

MySQL vs. Other Programming Languages: A Comparison MySQL vs. Other Programming Languages: A Comparison Apr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Solve database connection problem: a practical case of using minii/db library Solve database connection problem: a practical case of using minii/db library Apr 18, 2025 am 07:09 AM

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL for Beginners: Getting Started with Database Management MySQL for Beginners: Getting Started with Database Management Apr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

Solve MySQL mode problem: The experience of using the TheliaMySQLModesChecker module Solve MySQL mode problem: The experience of using the TheliaMySQLModesChecker module Apr 18, 2025 am 08:42 AM

When developing an e-commerce website using Thelia, I encountered a tricky problem: MySQL mode is not set properly, causing some features to not function properly. After some exploration, I found a module called TheliaMySQLModesChecker, which is able to automatically fix the MySQL pattern required by Thelia, completely solving my troubles.

See all articles