|
先给大家看几个实例的错误分析与解决方案。 1.ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/data/mysql/mysql.sock' - 问题分析:可能是数据库没有启动或者是端口被防火墙禁止。
- 解决方法:启动数据库或者防火墙开放数据库监听端口。
2.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 1)修改 my.cnf 主配置文件,在[mysqld]下添加 skip-grant-tables,重启数据库。最后修改密码命令如下: mysql> use mysql;
mysql> update user set password=password("123456") where user="root";
再删除刚刚添加的 skip-grant-tables 参数,再重启数据库,使用新密码即可登录。 2)重新授权,命令如下: mysql> grant all on *.* to 'root'@'mysql-server' identified by '123456';
3.客户端报 Too many connections - 问题分析:连接数超出 Mysql 的最大连接限制。
- 解决方法:
- 1、在 my.cnf 配置文件里面增加连接数,然后重启 MySQL 服务。max_connections = 10000
- 2、临时修改最大连接数,重启后不生效。需要在 my.cnf 里面修改配置文件,下次重启生效。
set GLOBAL max_connections=10000;
4.Warning: World-writable config file '/etc/my.cnf' is ignored ERROR! MySQL is running but PID file could not be found - 问题分析:MySQL 的配置文件/etc/my.cnf 权限不对。
- 解决方法:
chmod 644 /et/my.cnf
5.InnoDB: Error: page 14178 log sequence number 29455369832 InnoDB: is in the future! Current system log sequence number 29455369832 - 问题分析:innodb 数据文件损坏。
- 解决方法:修改 my.cnf 配置文件,在[mysqld]下添加 innodb_force_recovery=4, 启动数据库后备份数据文件,然后去掉该参数,利用备份文件恢复数据。
6.从库的 Slave_IO_Running 为 NO - 问题分析:主库和从库的 server-id 值一样.
- 解决方法:修改从库的 server-id 的值,修改为和主库不一样,比主库低。修改完后重启,再同步即可!
7.从库的 Slave_IO_Running 为 NO问题 - 问题分析:造成从库线程为 NO 的原因会有很多,主要原因是主键冲突或者主库删除或更新数据, 从库找不到记录,数据被修改导致。通常状态码报错有 1007、1032、1062、1452 等。
- 解决方法一:
mysql> stop slave;
mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql> start slave;
set global read_only=true;
8.Error initializing relay log position: I/O error reading the header from the binary log - 分析问题:从库的中继日志 relay-bin 损坏.
- 解决方法:手工修复,重新找到同步的 binlog 和 pos 点,然后重新同步即可。
mysql> CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.xxx',MASTER_LOG_POS=xxx; 维护过MySQL的运维或DBA都知道,经常会遇到的一些错误信息中有一些类似10xx的代码。 Replicate_Wild_Ignore_Table:
Last_Errno: 1032
Last_Error: Could not execute Update_rows event on table xuanzhi.test; Can't find record in 'test', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000004, end_log_pos 3704但是,如果不深究或者之前遇到过,还真不太清楚,这些代码具体的含义是什么?这也给我们排错造成了一定的阻碍。 所以,今天民工哥就把主从同步过程中一些常见的错误代码,它的具体说明给大家整理出来了。 MySQL常见错误代码说明:
|