mysql故障和错误总结

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

1.用户和网站无法访问数据库中的表

提示:Table ‘xxx’ is marked as crashed and should be repaired

图:

wKiom1LMqXaBA0raAAAfRuGh21U287.jpg

   

解决方法:myisamchk -c -r ../data/tablename/ecs_pay_log.MYI      --忧化和修复一下表


2.启动mysql出现错误(权限有问题)

[root@centos bin]# ./mysql -u root -p   --启动mysql出错
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@centos bin]#


解决方法:

[root@centos bin]# useradd -s /sbin/nolog -r -M mysql    --创建mysql系统用户
[root@centos mysql]# pwd
/usr/local/mysql
[root@centos mysql]# chown -R root:mysql .   --修改mysql根目录的权限
[root@centos mysql]# chown -R mysql:mysql /var/lib/mysql/  --修改数据文件目录权限
[root@centos mysql]# cd bin/
[root@centos bin]# ./mysql_install_db &    --初使化数据库
[2] 2973
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h centos password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[2]+  Done                    ./mysql_install_db
[root@centos bin]# ./mysqld_safe &    --启动数据库
[1] 3040
Starting mysqld daemon with databases from /var/lib/mysql
[root@centos bin]#


测试:

[root@centos bin]# ./mysql -u root -p   --成功登陆
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.40 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.03 sec)
mysql>


3.缺少ncurses-devel包

checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for termcap functions library... configure: error: No curses/termcap library found


解决方法:

[root@centos1 mysql-5.0.40]$ yum install ncurses-devel


4.没有mysql.sock文件

[root@centos1 bin]$ ./mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@centos1 bin]$


解决方法:

[root@centos1 bin]$ find / -name mysql.sock
/var/lib/mysql/mysql.sock
[root@centos1 bin]$ ln -s /var/lib/mysql/mysql.sock  /tmp/mysql.sock
[root@centos1 bin]$ ./mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.40 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>


5.没有mysql.sock文件

[root@centos bin]# ./mysql -u root -p -S /var/lib/mysql/mysql.sock
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
[root@centos bin]#


解决方法:

[root@centos mysql5.0]#  share/mysql/mysql.server restart
ERROR! MySQL manager or server PID file could not be found!
Starting MySQL SUCCESS!
[root@centos mysql5.0]#


测试:

[root@centos mysql5.0]# netstat -anp |grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      30734/mysqld
[root@centos mysql5.0]#  cd bin/
[root@centos bin]# ./mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.40 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>


6.启动数据库出现(

shared libraries:libmysqlclient.so.16:cannot open shared object file:No such file or directory)

错误信息:

[root@redhat1 mysql-5.1.51]# ./configure --prefix=/usr/local/mysql5.1/ && make && make install    --安装数据库
[root@redhat1 mysql-5.1.51]# cd /usr/local/mysql5.1/
[root@redhat1 mysql5.1]# cp -a share/mysql/mysql.server  /etc/init.d/mysqld
[root@redhat1 mysql5.1]# chmod  755 /etc/init.d/mysqld   --服务启动文件
[root@redhat1 mysql5.1]# /etc/init.d/mysqld restart
Shutting down MySQL.                                       [  OK  ]
Starting MySQL.                                            [  OK  ]
[root@redhat1 mysql5.1]# netstat -an |grep 3306    --启动成功
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN
[root@redhat1 mysql5.1]# ./bin/mysql -u root -p    --登陆出错
mysql: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory


解决方法:

[root@redhat1 mysql5.1]# ldconfig -v |grep mysql   --没有mysql模块
[root@redhat1 mysql5.1]# vim /etc/ld.so.conf     --添加模块
/usr/local/mysql5.1/lib/mysql/
/usr/lib/mysql
[root@redhat1 mysql5.1]# ldconfig  -v |grep mysql   --查看mysql模块
/usr/local/mysql5.1/lib/mysql:
libmysqlclient.so.16 -> libmysqlclient.so.16.0.0
libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
/usr/lib/mysql:
libmysqlclient.so.16 -> libmysqlclient.so1
[root@redhat1 mysql5.1]# ln -s /usr/local/mysql5.1/lib/mysql/libmysqlclient.so /usr/lib/mysql/libmysqlclient.so
[root@redhat1 mysql5.1]# ./bin/mysql -u root -p    --启动成功
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.51-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

 

7.启动mysql报错

2015-04-17 10:17:18 26168 [Note] InnoDB: Completed initialization of buffer pool
2015-04-17 10:17:18 26168 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-04-17 10:17:19 26168 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-04-17 10:17:20 26168 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-04-17 10:17:20 26168 [Warning] InnoDB: New log files created, LSN=1648900
2015-04-17 10:17:20 7fddd7d9d720 InnoDB: Expected to open 3 undo tablespaces but was able
2015-04-17 10:17:20 7fddd7d9d720 InnoDB: to find only 0 undo tablespaces.
2015-04-17 10:17:20 7fddd7d9d720 InnoDB: Set the innodb_undo_tablespaces parameter to the
2015-04-17 10:17:20 7fddd7d9d720 InnoDB: correct value and retry. Suggested value is 0
2015-04-17 10:17:20 26168 [ERROR] Plugin 'InnoDB' init function returned error.
2015-04-17 10:17:20 26168 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-04-17 10:17:20 26168 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-04-17 10:17:20 26168 [ERROR] Aborting


2015-04-17 10:17:20 26168 [Note] Binlog end
2015-04-17 10:17:20 26168 [Note] ./bin/mysqld: Shutdown complete
[root@tong1 mysql-5.6.22]#


解决方法:

[root@tong1 mysql-5.6.22]# rm -rf data/ib_logfile*        --删除ib_logfile0或1事物日志文件,或者是修改了数据库的配置文件参数产生异常

[root@tong1 mysql-5.6.22]# /etc/init.d/mysqld restart
 ERROR! MySQL server PID file could not be found!
Starting MySQL... SUCCESS! 
[root@tong1 mysql-5.6.22]# 


8.MHA架构中的错误

Tue Apr 28 15:15:36 2015 - [error][/usr/local/share/perl5/MHA/ServerManager.pm, ln193] There is no alive slave. We can't do failover
Tue Apr 28 15:15:36 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln383] Error happend on checking configurations.  at /usr/local/share/perl5/MHA/MasterMonitor.pm line 298
Tue Apr 28 15:15:36 2015 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln478] Error happened on monitoring servers.


解决方法:

(1).删除健康检查文件  rm -rf /var/log/masterha/app1/app1.master_status.health 
(2).在宕机的数据库中重新同步到主服务器 change master to master_host...............

(3).检查复制是否出错 masterha_check_repl --conf=/etc/mysqlmha/conf/app1.cnf 



9.MMM架构中的错误

[root@tong3 ~]# /etc/init.d/mysql-mmm-monitor  start
Daemon bin: '/usr/sbin/mmm_mond'
Daemon pid: '/var/run/mmm_mond.pid'
Starting MMM Monitor daemon: Base class package "Class::Singleton" is empty.
    (Perhaps you need to 'use' the module which defines that package first,
    or make that module available in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
 at /usr/share/perl5/vendor_perl/MMM/Monitor/Agents.pm line 2
BEGIN failed--compilation aborted at /usr/share/perl5/vendor_perl/MMM/Monitor/Agents.pm line 2.
Compilation failed in require at /usr/share/perl5/vendor_perl/MMM/Monitor/Monitor.pm line 15.
BEGIN failed--compilation aborted at /usr/share/perl5/vendor_perl/MMM/Monitor/Monitor.pm line 15.
Compilation failed in require at /usr/sbin/mmm_mond line 28.
BEGIN failed--compilation aborted at /usr/sbin/mmm_mond line 28.
failed
[root@tong3 ~]#


解决方法:

故障说明:是没有编译Class::Singleton相关的包

[root@tong3 init.d]# perl -MCPAN -e shell
Terminal does not support AddHistory.
cpan[1]> Class::Singleton         --没有找到相关的包
Catching error: "Can't locate object method \"Singleton\" via package \"Class\" (perhaps you forgot to load \"Class\"?) at /usr/share/perl5/CPAN.pm line 375, <FIN> line 1.\cJ" at /usr/share/perl5/CPAN.pm line 391
    CPAN::shell() called at -e line 1

cpan[2]> Class
Unknown shell command 'Class'. Type ? for help.

cpan[3]> install Class::Singleton      --安装包
CPAN: Storable loaded ok (v2.20)
Going to read '/root/.cpan/Metadata'
  Database was generated on Tue, 28 Apr 2015 04:17:02 GMT
CPAN: LWP::UserAgent loaded ok (v5.833)
CPAN: Time::HiRes loaded ok (v1.9721)
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp19898'. Giving up on it. at /usr/share/perl5/CPAN/Index.pm line 225
Fetching with LWP:
  http://www.perl.org/CPAN/authors/01mailrc.txt.gz
Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
.............................省略  .......................

  /usr/bin/make test -- OK
Warning (usually harmless): 'YAML' not installed, will not store persistent state
Running make install
Prepending /root/.cpan/build/Class-Singleton-1.5-nrETFl/blib/arch /root/.cpan/build/Class-Singleton-1.5-nrETFl/blib/lib to PERL5LIB for 'install'
Manifying blib/man3/Class::Singleton.3pm
Installing /usr/local/share/perl5/Class/Singleton.pm
Installing /usr/local/share/man/man3/Class::Singleton.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
  SHAY/Class-Singleton-1.5.tar.gz
  /usr/bin/make install UNINST=1 -- OK         --安装成功
Warning (usually harmless): 'YAML' not installed, will not store persistent state

cpan[4]> exit
Terminal does not support GetHistory.
Lockfile removed.
[root@tong3 init.d]# 


9.备份mysql时出现表损坏

错误提示:cannot load form mysql.proc the table is probably corrupted


解决方法:

[root@goodsph2 ~]# mysql_upgrade -u root -p    --更新表结构

[root@goodsph2 ~]# /etc/init.d/mysqld restart      --重启数据库就好了

Shutting down MySQL... SUCCESS! 
Starting MySQL.. SUCCESS! 
[root@goodsph2 ~]# 









本文转自 z597011036 51CTO博客,原文链接:http://blog.51cto.com/tongcheng/1349528,如需转载请自行联系原作者
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
6月前
|
SQL 关系型数据库 MySQL
mysql常见故障汇总和处理
mysql常见故障汇总和处理
|
3月前
|
缓存 NoSQL 关系型数据库
MySQL缓存策略(一致性问题、数据同步以及缓存故障)
MySQL缓存策略(一致性问题、数据同步以及缓存故障)
55 1
|
6月前
|
关系型数据库 MySQL 网络安全
Mysql主从同步时Slave_SQL_Running状态为Yes , 但是Slave_IO_Running状态为Connecting以及NO的情况故障排除
当使用Navicat工具打开这三个数据库时 , 发现主库和从库的数据不同
72 0
|
10月前
|
运维 关系型数据库 MySQL
WDCP MYSQL 5.5.44 升级故障处理一例
WDCP MYSQL 5.5.44 升级故障处理一例
|
11月前
|
SQL 缓存 关系型数据库
故障案例:MySQL唯一索引有重复值,官方却说This is not a bug
故障案例:MySQL唯一索引有重复值,官方却说This is not a bug
132 0
|
存储 关系型数据库 MySQL
MySQL出现Data too long for column...(错误号1406)和 Data truncated for column...(错误号1265)
MySQL出现Data too long for column...(错误号1406)和 Data truncated for column...(错误号1265)
582 0
MySQL出现Data too long for column...(错误号1406)和 Data truncated for column...(错误号1265)
|
数据可视化 关系型数据库 MySQL
mysql:解压版MySQL通过SQLyog可视化密码过期问题(错误号码1862)
mysql:解压版MySQL通过SQLyog可视化密码过期问题(错误号码1862)
348 0
mysql:解压版MySQL通过SQLyog可视化密码过期问题(错误号码1862)
|
SQL 存储 关系型数据库
MYSQL 索引成本计算,为什么MYSQL预判后选择了错误索引?
IO 成本: 即从磁盘把数据加载到内存的成本,默认情况下,读取数据页的 IO 成本是 1,MySQL 是以页的形式读取数据的,即当用到某个数据时,并不会只读取这个数据,而会把这个数据相邻的数据也一起读到内存中,这就是有名的程序局部性原理,所以 MySQL 每次会读取一整页,一页的成本就是 1。所以 IO 的成本主要和页的大小有关
219 0
|
SQL 关系型数据库 MySQL
mysql中lock tables与unlock tables(锁表/解锁)使用总结
mysql中lock tables与unlock tables(锁表/解锁)使用总结
282 0
|
关系型数据库 MySQL
mysql启动提示unrecognized service错误
mysql启动提示unrecognized service错误
591 0