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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Alibaba Cloud announced that the 2024 Yunqi Conference will be held in Hangzhou from September 19th to 21st. Free application for free tickets Alibaba Cloud announced that the 2024 Yunqi Conference will be held in Hangzhou from September 19th to 21st. Free application for free tickets Aug 07, 2024 pm 07:12 PM

According to news from this website on August 5, Alibaba Cloud announced that the 2024 Yunqi Conference will be held in Yunqi Town, Hangzhou from September 19th to 21st. There will be a three-day main forum, 400 sub-forums and parallel topics, as well as nearly four Ten thousand square meters of exhibition area. Yunqi Conference is free and open to the public. From now on, the public can apply for free tickets through the official website of Yunqi Conference. An all-pass ticket of 5,000 yuan can be purchased. The ticket website is attached on this website: https://yunqi.aliyun.com/2024 /ticket-list According to reports, the Yunqi Conference originated in 2009 and was originally named the First China Website Development Forum. In 2011, it evolved into the Alibaba Cloud Developer Conference. In 2015, it was officially renamed the "Yunqi Conference" and has continued to successful move

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

The difference between oracle database and mysql The difference between oracle database and mysql May 10, 2024 am 01:54 AM

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.

See all articles