Home Database Mysql Tutorial MySQL下常见的启动失败与备份失败问题的解决教程_MySQL

MySQL下常见的启动失败与备份失败问题的解决教程_MySQL

May 27, 2016 pm 01:45 PM
m mysql Startup failed Tutorial

启动失败
重启服务器后-->重启应用服务(Confluence)-->报错,数据库连接失败(mysql设置了开机自启动)-->查看mysql数据库状态:

[root@fisheye ~]# ps -ef | grep mysql
root   25555 21974 0 11:28 pts/0  00:00:00 grep mysql
Copy after login

启动mysql服务器

[root@fisheye data]# service mysql start
Copy after login

MySQL server PID file could not be found![失败]
Starting MySQL.............. ERROR! The server quit without updating PID file (/mydata/data/fisheye..pid).[失败]
Copy after login

查看错误日志:

[root@fisheye data]# tail -100 fisheye.err
Copy after login

InnoDB: Last MySQL binlog file position 0 337403929, file name ./mysql-bin.000016
141013 1:13:28 InnoDB: Waiting for the background threads to start
141013 1:13:29 InnoDB: 5.5.33 started; log sequence number 1006647152
17:13:29 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
di141013 01:13:29 mysqld_safe mysqld from pid file /mydata/data/fisheye.pid ended
Copy after login

未发现明显性错误提示,所以手动创建一个pid文件试试

[root@fisheye data]# touch /mydata/data/fisheye.pi
Copy after login

再进行重启服务:

[root@fisheye data]# service mysql restart
Copy after login

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Copy after login

突然想到之前看过此类报错的文章,记得有可能是磁盘空间不足导致的mysql无法启动。

[root@fisheye data]# df -h
Copy after login

(文件系统 容量 已用 可用 已用% 挂载点)

/dev/sda1       9.5G 9.5G 0 100% /
/dev/sda4       5.5G 1.3G 4.0G 24% /mnt/backup
/dev/mapper/IhuilianVG-IhuilianLV00
            22G 4.2G  17G 20% /var/www/app
tmpfs         1.3G   0 1.3G  0% /dev/shm
Copy after login

果然如此,下面罗列一些类似问题(无法启动)的解决思路:
1.可能是datadir目录存在的分区满了(df -h )
解决方法:打开配置文件/etc/my.cnf,在[mysqld]节下重新指定数据目录(datadir),并将原来的数据目录迁移到重新制定的数据目录处
关于迁移:(1)、cp或者tar的时候一定要把权限给带上,但是为防止意外建议再授权一次;(2)、数据比较大时一定要先压缩再迁移,保证完整性,特别是scp到其他机器时可能会超时所以一定要压缩(tar.gz);(3)、若是移动至另外的服务器一定要保证mysql版本一致。

2.可能是/mydata/data/fisheye.pid文件没有写的权限
解决方法 :给予权限,执行 “chown -R mysql:mysql /mydata/data/” 然后重新启动mysqld!

3.可能进程里已经存在mysql进程
解决方法:用命令“ps -ef|grep mysqld”查看是否有mysqld进程,如果有使用“kill -9 进程号”杀死,然后重新启动mysqld!

4.可能是第二次在机器上安装mysql,有残余数据影响了服务的启动。
解决方法:去mysql的数据目录/data看看,如果存在mysql-bin.index,就赶快把它删除掉吧,它就是罪魁祸首了。

5.skip-federated字段问题(报错信息:[ERROR] /mydata/data/mysql/libexec/mysqld: unknown option '--skip-federated')
解决方法:检查一下/etc/my.cnf文件中有没有没被注释掉的skip-federated字段,如果有就立即注释掉吧。

6.selinux惹的祸,如果是centos系统,默认会开启selinux
解决方法:关闭它,打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器试试。

备份失败
说明
执行 mysqldump 时出现找不到某一个 tables 并且中断执行?及锁表后延伸出现的问题记录!
问题及方案如下
Error Meaage: 执行mysqldump 时出现找不到某一个 tables 并且中断执行

[root@test100 data]# mysqldump fx > fx.sql
Copy after login

mysqldump: Got error: 1146: Table 'user_suggest_report' doesn't exist when using LOCK TABLES
Copy after login

考虑加上 --skip-lock-tables或者-R进行锁表试试,也是不行,信息如下

[root@test100 data]#mysqldump --skip-lock-tables fx > fx.sql
Copy after login

Error: Couldn't read status information for table vote_results () mysqldump: Couldn't execute 'show create table `user_suggest_report`': Table 'fx.user_suggest_report' doesn't exist (1146)
Copy after login

登陆服务器查看是否存在此表

 [root@test100 data]#mysql -h127.0.0.1 -D fx
 mysql> show tables;      #查看所有的表 --> 发现是表存在的
Copy after login

+--------------------------------+
| Tables_in_fx          |
+--------------------------------+
| user_suggest_report      |
+--------------------------------+
80 rows in set (0.00 sec)
Copy after login

删除此表

mysql> drop table user_suggest_report;      #既然是存在的,但是系统却认定不存在说明存在问题,索性想删除试试
Copy after login

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user_suggest_report' at line 1
Copy after login

进入mysql存储目录下将其数据表移动或删除

[root@test100 data]# cat /etc/my.cnf | grep datadir
datadir=/var/lib/mysql
[root@test100 data]# cd /var/lib/mysql/fx/
[root@test100 fx]# mv user_suggest_report.frm /data
Copy after login

重启mysql服务器

[root@test100 fx]# service mysqld restart
Copy after login

重新备份操作

[root@test100 data]# mysqldump fx > fx.150109.sql  #操作成功
Copy after login

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

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
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)

MySQL: The Ease of Data Management for Beginners MySQL: The Ease of Data Management for Beginners Apr 09, 2025 am 12:07 AM

MySQL is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

How to open phpmyadmin How to open phpmyadmin Apr 10, 2025 pm 10:51 PM

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

How to create navicat premium How to create navicat premium Apr 09, 2025 am 07:09 AM

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

MySQL and SQL: Essential Skills for Developers MySQL and SQL: Essential Skills for Developers Apr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

How to create a new connection to mysql in navicat How to create a new connection to mysql in navicat Apr 09, 2025 am 07:21 AM

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

How to recover data after SQL deletes rows How to recover data after SQL deletes rows Apr 09, 2025 pm 12:21 PM

Recovering deleted rows directly from the database is usually impossible unless there is a backup or transaction rollback mechanism. Key point: Transaction rollback: Execute ROLLBACK before the transaction is committed to recover data. Backup: Regular backup of the database can be used to quickly restore data. Database snapshot: You can create a read-only copy of the database and restore the data after the data is deleted accidentally. Use DELETE statement with caution: Check the conditions carefully to avoid accidentally deleting data. Use the WHERE clause: explicitly specify the data to be deleted. Use the test environment: Test before performing a DELETE operation.

How to execute sql in navicat How to execute sql in navicat Apr 08, 2025 pm 11:42 PM

Steps to perform SQL in Navicat: Connect to the database. Create a SQL Editor window. Write SQL queries or scripts. Click the Run button to execute a query or script. View the results (if the query is executed).

See all articles