MySQL下常见的启动失败与备份失败问题的解决教程
启动失败
重启服务器后-->重启应用服务(Confluence)-->报错,数据库连接失败(mysql设置了开机自启动)-->查看mysql数据库状态:
[root@fisheye~]#ps-ef|grepmysql root2555521974011:28pts/000:00:00grepmysql
启动mysql服务器
[root@fisheyedata]#servicemysqlstart
MySQLserverPIDfilecouldnotbefound![失败] StartingMySQL..............ERROR!TheserverquitwithoutupdatingPIDfile(/mydata/data/fisheye..pid).[失败]
查看错误日志:
[root@fisheyedata]#tail-100fisheye.err
InnoDB:LastMySQLbinlogfileposition0337403929,filename./mysql-bin.000016 1410131:13:28InnoDB:Waitingforthebackgroundthreadstostart 1410131:13:29InnoDB:5.5.33started;logsequencenumber1006647152 17:13:29UTC-mysqldgotsignal11; Thiscouldbebecauseyouhitabug.Itisalsopossiblethatthisbinary oroneofthelibrariesitwaslinkedagainstiscorrupt,improperlybuilt, ormisconfigured.Thiserrorcanalsobecausedbymalfunctioninghardware. Wewilltryourbesttoscrapeupsomeinfothatwillhopefullyhelp di14101301:13:29mysqld_safemysqldfrompidfile/mydata/data/fisheye.pidended
未发现明显性错误提示,所以手动创建一个pid文件试试
[root@fisheyedata]#touch/mydata/data/fisheye.pi
再进行重启服务:
[root@fisheyedata]#servicemysqlrestart
ERROR2002(HY000):Can'tconnecttolocalMySQLserverthroughsocket'/tmp/mysql.sock'(2)
突然想到之前看过此类报错的文章,记得有可能是磁盘空间不足导致的mysql无法启动。
[root@fisheyedata]#df-h
(文件系统 容量 已用可用已用%挂载点)
/dev/sda19.5G9.5G0100%/ /dev/sda45.5G1.3G4.0G24%/mnt/backup /dev/mapper/IhuilianVG-IhuilianLV00 22G4.2G17G20%/var/www/app tmpfs1.3G01.3G0%/dev/shm
果然如此,下面罗列一些类似问题(无法启动)的解决思路:
1.可能是datadir目录存在的分区满了(df-h)
解决方法:打开配置文件/etc/my.cnf,在[mysqld]节下重新指定数据目录(datadir),并将原来的数据目录迁移到重新制定的数据目录处
关于迁移:(1)、cp或者tar的时候一定要把权限给带上,但是为防止意外建议再授权一次;(2)、数据比较大时一定要先压缩再迁移,保证完整性,特别是scp到其他机器时可能会超时所以一定要压缩(tar.gz);(3)、若是移动至另外的服务器一定要保证mysql版本一致。
2.可能是/mydata/data/fisheye.pid文件没有写的权限
解决方法:给予权限,执行“chown-Rmysql:mysql/mydata/data/” 然后重新启动mysqld!
3.可能进程里已经存在mysql进程
解决方法:用命令“ps-ef|grepmysqld”查看是否有mysqld进程,如果有使用“kill-9 进程号”杀死,然后重新启动mysqld!
4.可能是第二次在机器上安装mysql,有残余数据影响了服务的启动。
解决方法:去mysql的数据目录/data看看,如果存在mysql-bin.index,就赶快把它删除掉吧,它就是罪魁祸首了。
5.skip-federated字段问题(报错信息:[ERROR]/mydata/data/mysql/libexec/mysqld:unknownoption'--skip-federated')
解决方法:检查一下/etc/my.cnf文件中有没有没被注释掉的skip-federated字段,如果有就立即注释掉吧。
6.selinux惹的祸,如果是centos系统,默认会开启selinux
解决方法:关闭它,打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器试试。
备份失败
说明
执行mysqldump时出现找不到某一个tables并且中断执行?及锁表后延伸出现的问题记录!
问题及方案如下
ErrorMeaage:执行mysqldump时出现找不到某一个tables并且中断执行
[root@test100data]#mysqldumpfx>fx.sql
mysqldump:Goterror:1146:Table'user_suggest_report'doesn'texistwhenusingLOCKTABLES
考虑加上--skip-lock-tables或者-R进行锁表试试,也是不行,信息如下
[root@test100data]#mysqldump--skip-lock-tablesfx>fx.sql
Error:Couldn'treadstatusinformationfortablevote_results()mysqldump:Couldn'texecute'showcreatetable`user_suggest_report`':Table'fx.user_suggest_report'doesn'texist(1146)
登陆服务器查看是否存在此表
[root@test100data]#mysql-h127.0.0.1-Dfx mysql>showtables;#查看所有的表-->发现是表存在的
+--------------------------------+ |Tables_in_fx| +--------------------------------+ |user_suggest_report| +--------------------------------+ 80rowsinset(0.00sec)
删除此表
mysql>droptableuser_suggest_report;#既然是存在的,但是系统却认定不存在说明存在问题,索性想删除试试
ERROR1064(42000):YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverversionfortherightsyntaxtousenear'user_suggest_report'atline1
进入mysql存储目录下将其数据表移动或删除
[root@test100data]#cat/etc/my.cnf|grepdatadir datadir=/var/lib/mysql [root@test100data]#cd/var/lib/mysql/fx/ [root@test100fx]#mvuser_suggest_report.frm/data
重启mysql服务器
[root@test100fx]#servicemysqldrestart
重新备份操作
[root@test100data]#mysqldumpfx>fx.150109.sql#操作成功