1.mysql errors:message from server: "Host 'xxx' is blocked because of many connection errors; unblock

数据库连接抛了异常:null,  message from server: "Host 'PC-20130201IBXI' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"。

原因:同一个ip在短时间内产生太多(超过mysql数据库max_connection_errors的最大值)中断的数据库连接而导致的阻塞;解决办法如下:

mysqladmin -u root -p  flush-hosts

2. MySQL 5.7.17 安装报错CMake Error at cmake/boost.cmake:81 (MESSAGE)

解决办法是:
1).在/usr/local下创建一个名为boost的文件夹
    mkdir -p /usr/local/boost
2).进入这个新创建的文件夹然后下载boost
    wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
3).解压
    tar -xvzf boost_1_59_0.tar.gz
4).继续cmake,添加上红色部分

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPILATION_COMMENT='Mysqlma' \
-DWITH_READLINE=ON \
-DWITH_BOOST=/usr/local/boost \
-DSYSCONFDIR=/data/mysqldata/3306 \
-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock

3.Mysql重启失败原因剖析一

Timeout error occurred trying to start MySQL Daemon.

当修改完某些配置之后,打算/etc/init.d/mysqld restart,发现重启失败。

首先看mysql的日志文件查找原因:tail /var/log/mysqld.log

发现为用户权限问题:

120724 15:52:02 [ERROR] /usr/libexec/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13)
120724 15:52:02 [ERROR] Can't start server: can't create PID file: Permission denied
120724 15:52:02  mysqld ended
========

solution

========

cd /var/lib/

ls -l | grep mysqld

看看用户名和用户组是否均为mysql,如果不是,则重新将权限调整回mysql默认值。

chown -R mysql:mysql mysqld

chmod 755 -R mysqld

现在试试重启服务:/etc/init.d/mysqld start

如果重启仍失败,则还有可能是执行文件的权限还有问题:

cd /var/run/

ls -l | grep mysqld

看看用户名和用户组是否均为mysql,如果不是,则重新将权限调整回mysql默认值。

chown -R mysql:mysql mysqld

4.mysql数据库通过yum安装后启动不了。如下:

MySQL Daemon failed to start.
Starting mysqld: [FAILED]

查看日志

[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

输入mysql_install_db命令后,重启mysql成功。

[root@localhost etc]# mysql_install_db
Installing MySQL system tables...

[root@localhost etc]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]

5.一次mysql slave故障的解决过程

mysql> show slave status\G 
Last_SQL_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master’s binary log is corrupted (you can check this by running ‘mysqlbinlog’ on the binary log), the slave’s relay log is corrupted (you can check this by running ‘mysqlbinlog’ on the relay log), a network problem, or a bug in the master’s or slave’s MySQL code. If you want to check the master’s binary log or slave’s relay log, you will be able to know their names by issuing ‘SHOW SLAVE STATUS’ on this slave. Error_code: 1594 
看样子,应该由于网络原因 slave relay log损坏了

查看 mysql 日志: 
170306 12:34:08 [Note] Slave SQL thread initialized, starting replication in log ‘mysql-bin.000033’ at position 77270703, relay log ‘./HK3ASERVER-relay-bin.066281’ position: 10604437 
170306 12:34:08 [ERROR] Error in Log_event::read_log_event(): ‘read error’, data_len: 67, event_type: 19 
170306 12:34:08 [ERROR] Error reading relay log event: slave SQL thread aborted because of I/O error 
170306 12:34:08 [ERROR] Slave SQL: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master’s binary log is corrupted (you can check this by running ‘mysqlbinlog’ on the binary log), the slave’s relay log is corrupted (you can check this by running ‘mysqlbinlog’ on the relay log), a network problem, or a bug in the master’s or slave’s MySQL code. If you want to check the master’s binary log or slave’s relay log, you will be able to know their names by issuing ‘SHOW SLAVE STATUS’ on this slave. Error_code: 1594 
170306 12:34:08 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with “SLAVE START”. We stopped at log ‘mysql-bin.000033’ position 77270703

mysql> stop slave;

mysql> change master to Master_Log_File=’mysql-bin.000033’, Master_Log_Pos=77270703; 
This operation cannot be performed with a running slave; run STOP SLAVE first

mysql> show slave status\G 
发现IO_THREAD线程一直存在停不掉

最后,将mysql/data目录下的 master.info 备走,重新启动 mysql

mysql> show slave status\G 
发现 slave 已彻底停掉了

mysql> reset slave; 
mysql> change master to Master_Log_File=’mysql-bin.000033’, Master_Log_Pos=77270703; 
mysql> start slave; 
Slave_IO_Running: Yes 
Slave_SQL_Running: Yes

slave 恢复正常

6.主从复制或主主复制时发生如下情况
Slave_IO_Running: Connecting

原因
1)网络不通
2)pos位置不对
3)repl密码不对
4)  防火墙规则阻拦或者selinux没关
5)  server-id不对

7.mysql启动失败报错之一

[ERROR] Can't create interrupt-thread (error 11, errno: 11)


Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug'

InnoDB: Error: pthread_create returned 11

1.)直接处理方法,重启服务器,刷新进程连接。

2.)修改max user processes

ulimit  -u 查看

修改/etc/security/limits.conf文件,添加:
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535          增加max user processes
* hard nproc 65535

查看/etc/security/limits.d目录是否有文件“90-nproc.conf”,没有的话新建该文件,文件,内容写为:
* soft nproc 65535
* hard nproc 65535

退出(logout)重新登录后,使用ulimit -a查看系统参数

 8.ERROR! The server quit without updating PID file (/usr/local/mysql/var/LNMP.pid)之一

[root@LNMP ~]# /etc/init.d/mysql start

Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/var/LNMP.pid).

查看错误日志
  1. root@LNMP var]# tail -f /usr/local/mysql/var/LNMP.err
  2. /usr/local/mysql/bin/mysqld: Can't create/write to file '/tmp/ibJb9vcs' (Errcode: 13)
  3. 161201  8:45:41  InnoDB: Error: unable to create temporary file; errno: 13
  4. 161201  8:45:41 [ERROR] Plugin 'InnoDB' init function returned error.
  5. 161201  8:45:41 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
  6. 161201  8:45:41 [ERROR] Unknown/unsupported storage engine: InnoDB
  7. 161201  8:45:41 [ERROR] Aborting
  8. 161201  8:45:41 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
  9. 161201 08:45:41 mysqld_safe mysqld from pid file /usr/local/mysql/var/LNMP.pid ended

错误日志提示13错误,innodb不能创建临时文件

解决方法
给临时文件加777权限
root@LNMP var]# chmod 777 /tmp  

再次启动mysql,mysql正常启动!

9.Starting MySQL...The server quit without updating PID file 之二

1) 问题

[root@localhost mysql]# /etc/rc.d/init.d/mysql status
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
[root@localhost mysql]# /etc/rc.d/init.d/mysql start
Starting MySQL...The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).                              [FAILED]

2 )原因

没有初始化权限表

3 )解决办法

#cd /usr/local/mysql(进入mysql安装目录)
#chown -R mysql.mysql .
#su - mysql
$cd server
$scripts/mysql_install_db

4 )解决过程

[root@localhost ~]# cd /usr/local/mysql

[root@localhost mysql]# chown -R mysql.mysql .
[root@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd /usr/local/mysql
[mysql@localhost mysql]$ scripts/mysql_install_db
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:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./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 ./bin/mysqlbug script!

[mysql@localhost mysql]$ /usr/local/mysql/bin/mysqld_safe --user=mysql &
[1] 11767
[mysql@localhost mysql]$ 120502 07:01:17 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
120502 07:01:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql status
MySQL running (11830)                                      [  OK  ]
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql start
Starting MySQL                                             [  OK  ]

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

起因:在VM 上将一数据库的数据文件(/var/lib/mysql整个文件夹)拷贝到另外一台VM上,然后新的VM 上启动MYSQL,结果报如下异常:(提示:冷备务必保证关闭服务)

[root@localhost mysql]# service mysql start
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
大部分的答案都是:
1). 注释/etc/my.cnf里的skip-federated注释掉即#skip-federated;
2). my.cnf文件配置过高,重新定义其中的参数(根据服务器情况定义);
3). 杀掉mysql_safe和mysqld进程,然后再重启;
4). 当前日志文件过大,超出了my.cnf中定义的大小(默认为64M),删除日志文件再重启;

5). 其他情况,查看日志文件(我的是localhost.localdomain.err,具体因人而异),然后具体分析;

问题解决:

其中,查看了日志内容,如下:

[root@localhost mysql]# less localhost.localdomain.err 
111203 22:09:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
^G/usr/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
111203 22:09:03 [ERROR] Aborting

111203 22:09:03 [Note] /usr/sbin/mysqld: Shutdown complete

111203 22:09:03 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended

但是我查看了我的目录文件,mysql-bin.index文件是存在的呀,奇怪:

[root@localhost mysql]# ll
total 49828
-rw-rw----. 1 mysql mysql 35651584 Dec  3 17:55 ibdata1
-rw-rw----. 1 mysql mysql  5242880 Dec  3 17:55 ib_logfile0
-rw-rw----. 1 mysql mysql  5242880 Dec  3 15:45 ib_logfile1
-rw-rw----. 1 mysql root      1376 Dec  3 22:02 localhost.localdomain.err
drwx--x--x. 2 mysql mysql     4096 Dec  3 17:55 mysql
-rw-rw----. 1 mysql mysql  4847020 Dec  3 17:55 mysql-bin.000001
-rw-rw----. 1 mysql mysql     1373 Dec  3 17:56 mysql-bin.000002
-rw-r--r--. 1 root  root        19 Dec  3 15:38 mysql-bin.index
drwx------. 2 mysql mysql     4096 Dec  3 17:55 performance_schema
-rw-r--r--. 1 root  root       116 Nov 25 21:03 RPM_UPGRADE_HISTORY
-rw-r--r--. 1 mysql mysql      116 Nov 25 21:03 RPM_UPGRADE_MARKER-LAST
drwxr-xr-x. 2 mysql mysql     4096 Dec  3 17:55 test

仔细看了下,咦?-rw-r--r--. 1 root  root        19 Dec  3 15:38 mysql-bin.index----难道是权限不够?于是将该文件加了写权限,重启,涛声依旧!!!噢噢!

难道是编码问题?难道是....继续猜测。。。问题还是没解决,后来我做了一件事情,将mysql-bin.index文件删除掉!或者修改其所有者所有组,重启!

[root@localhost mysql]# rm -rf mysql-bin.index 
[root@localhost mysql]#  
[root@localhost mysql]# service mysql start
Starting MySQL... SUCCESS!

补充:

很多时候,我们在做主从同步的时候,将数据库目录整体打包拷贝到从机上的时候,重启也往往会出现类似的问题,解决方法仍然是:

1)给MYSQL数据库数据目录权限:chown -R mysql:mysql 目录名称

2)务必保证MYSQL的进程是已经关闭了的;

另外要注意的地方就是:ib_*, mysql-bin-*, *.err(log文件)以及master-info和relay-info文件都是可以删除的,相当于重新初始化数据库的数据,但是前提是:

1)操作前要先关掉MYSQL的进程;

2)删掉文件后要重新启动MYSQL,如果有异常,请自行查看日志找问题,一般都比较好定位和解决。

 11.The server quit without updating PID file (/var/lib/mysql/tserver.pid).[FAILED] 之四

查看日志

[ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
[ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting

解决办法:

删除了如下三个文件:

[root@tserver mysql]# rm ibdata1  ib_logfile0  ib_logfile1 
rm: remove regular file `ibdata1'? yes      
rm: remove regular file `ib_logfile0'? yes
rm: remove regular file `ib_logfile1'? yes

重启 OK

12.启动报错 Neither host 'localhost.localdomain' nor 'localhost' could be looked up with...

解决方法:

查看cat /etc/hosts 发现什么文件也没有,编辑内容相关配置。

vim /etc/hosts 输入以下内容:127.0.0.1localhost.localdomain localhost

重启 OK

13.在执行scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysqldb命令时一直报错:

Can't locate Data/Dumper.pm 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 scripts/mysql_install_db line 42. BEGIN failed--compilation aborted at scripts/mysql_install_db line 42.

原因:

Fedora 19中yum的prel包中没有Dumper.pm文件。这时候只要执行以下命令就可以手动下载Dumper.pm文件

yum install 'perl(Data::Dumper)'

14.手动删除binlog日志后启动失败,报错如下:

Failed to open log (file './mysql-bin.000002', errno 2)
2018-01-16 13:59:13 4084 [ERROR] Could not open log file
2018-01-16 13:59:13 4084 [ERROR] Can't init tc log

解决办法:删除binlog索引文件

rm  -rf  mysql-bin.index

然后重启即可

15.CentOS7.2默认安装mariadb-server

报错:Failed to start mysqld.service: Unit not
found
当输入命令

~]# systemctl start mysql.service

要启动MySQL数据库是却是这样的提示

Failed to start mysqld.service: Unit not found

原因:
CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载

解决方法如下:

方法一:(常用+实用)
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 
rpm -ivh mysql-community-release-el7-5.noarch.rpm

service mysqld start

方法二:

  首先需要安装mariadb-server

  ~]# yum install -y mariadb-server

  启动服务

  ~]# systemctl start mariadb.service

  添加到开机启动

  ~]# systemctl enable mariadb.service

进行一些安全设置,以及修改数据库管理员密码

  ~]# mysql_sceure_installation

至此完成!

可以测试一下

  ~]# mysql -u root -p

后续积累中....

转载于:https://www.cnblogs.com/dannylinux/p/8082203.html

mysql问题处理积累相关推荐

  1. 【mysql】点滴积累

    一,replace mysql 中的replace 函数直接替换mysql 数据库中某字段中的特定字符串,不再需要自己写函数去替换,用起来很方便 格式:UPDATE table_name set  f ...

  2. mysql 001_Mysql错误积累001

    在cmd中使用mysql命令,学生信息表添加数据.使用load data方式简单批量导入数据. 准备好文本数据: xueshengxinxi.txt 文件  数据之间以tab键进行分割 执行 &quo ...

  3. Mysql sql语句积累

    分组排序 #alter table zxfw_offline_qa add zx_number varchar(50) COMMENT '咨询编号,提问日期+提问顺序' AFTER id;/* sel ...

  4. MySql应用原理分析系列文章目录

    本系列分析文章 为实际开发中的点点滴滴的总结,从最最简单的SQL 查询 到 综合分析查询 在分析 SQL 时,也会同时分析 mybatis .Hibernate 中的相关操作 每周更新 1-2 篇文章 ...

  5. 自语之Mysql隐式提交和事务隔离级别的关系

    前言 笔者自诩对Mysql的知识积累已经很不错了,现在看来不过是对CRUD操作比较熟悉罢了. 用了那么久的Mysql, 直到前几日才知道隐式提交和事务隔离级别的联系(内幕). (想自学习编程的小伙伴请 ...

  6. 【MySQL专题】MySQL中一条SQL是如何被执行的?---来自于令狐的独孤九剑

    [MySQL专题]MySQL中一条SQL是如何被执行的? 前言 ​ 大家好,我是令狐,欢迎来到令狐的独孤九剑**[MySQL专题]**这节课跟大家聊一聊MySQL中一条SQL是如何被执行的. MySQ ...

  7. mysql 死锁监控_mysql 死锁

    MySQL复制slave服务器死锁案例 原文:MySQL复制slave服务器死锁案例 MySQL复制刚刚触发了一个bug,该bug的触发条件是slave上Xtrabackup备份的时候执行flushs ...

  8. 如何构建企业内的 TiDB 自运维体系

    1. 前言 得物 App 从创立之初,关系型数据库一直使用的开源数据库产品 MySQL.和绝大部分互联网公司一样,随着业务高速增长.数据量逐步增多,单实例.单库.单表出现性能瓶颈和存储瓶颈.从选型和架 ...

  9. 【知识积累】SBT+Scala+MySQL的Demo

    一.背景 由于项目需要,需要在Sbt+Scala项目中连接MySQL数据库.由于之前使用Maven+Java进行依赖管理偏多,在Sbt+Scala方面也在不断进行摸索,特此记录,作为小模块知识的积累. ...

最新文章

  1. BBI:Eran Elinav组综述在微生物组研究中使用宏转录组
  2. BZOJ 2303 方格染色(带权并查集)
  3. LeetCode 06Z字形变换07整数反转
  4. VBoxManage命令详解
  5. Moose File System分布文件系统测试
  6. 深入 char * ,char ** ,char a[ ] ,char *a[]
  7. 使用kettle导入数据到ADB for PostgreSQL
  8. php中source,PHP中source #N问题的解决方法
  9. arduino水温度传感器数字显示_液晶显示屏应用示例以及程序详解
  10. 三菱PLC编程线缆制作
  11. 阶段3 3.SpringMVC·_03.SpringMVC常用注解_2 RequestBody注解
  12. R实例:非典型的数据可视化(一)
  13. VMware 中的操作系统切换模式后总是连接不上互联网可能的问题之一
  14. html5全屏(Fullscreen)
  15. 乔布斯自传预售即夺下销售冠军
  16. 今天好无聊……悟空……你变成女妖精吧……
  17. 伦敦 quant_伦敦统一用户组7
  18. 常见网络协议总结(五层自顶向下)
  19. Qt删除文件和文件夹
  20. WEB前端2020年更新实用代码段(持续更新)

热门文章

  1. Linux 下wifi 驱动开发(二)—— WiFi模块浅析
  2. Linux 下wifi 驱动开发(三)—— SDIO接口WiFi驱动浅析
  3. Linux常用错误码--errno-base.h
  4. word文档中插入特殊字符
  5. gvim同时处理中日韩文
  6. 在vue项目中操作元素ref案例;
  7. [html] 如何优化大数据列表(10万+)的性能?说说你的方案
  8. [css] 当使用@font-face的时候,为什么src中要加入local呢?
  9. 前端学习(2815):小程序学习之开发者工具介绍
  10. 前端学习(2482):关于接口的调错