ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

作者:admin 发布:2018-03-13 浏览:2725次

问题:

root@ubuntu-xenial:/usr/share/doc/zabbix-server-mysql# mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
root@ubuntu-xenial:/usr/share/doc/zabbix-server-mysql# service mysql start
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
root@ubuntu-xenial:/usr/share/doc/zabbix-server-mysql# systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Tue 2018-03-13 09:39:42 CST
  Process: 17825 ExecStart=/usr/sbin/mysqld (code=exited, status=2)
  Process: 17816 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, sta
 Main PID: 17825 (code=exited, status=2);         : 17826 (mysql-systemd-s)
   CGroup: /system.slice/mysql.service
           └─control
             ├─17826 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─17899 sleep 1
Mar 13 09:39:42 ubuntu-xenial systemd[1]: Starting MySQL Community Server...
Mar 13 09:39:43 ubuntu-xenial systemd[1]: mysql.service: Main process exited, code=exite
lines 1-13/13 (END)

待解决


查看

vim /var/log/mysql/error.log



InnoDB: End of page dump
2018-03-13T02:24:07.569579Z 0 [Note] InnoDB: Uncompressed page, stored checksum in field1 1749414094, calculated checksums for field1: crc32 1280349727/3430733431, innodb 2854149262, none 3735928559, stored checksum in field2 0, calculated checksums for field2: crc32 1280349727/3430733431, innodb 3492426672, none 3735928559,  page LSN 0 13840194, low 4 bytes of LSN at page end 0, page number (if stored to page already) 5, space id (if created with >= MySQL-4.1.1 and stored already) 911
InnoDB: Page may be an update undo log page
InnoDB: Page may be an index page where index id is 1848
2018-03-13T02:24:07.569606Z 0 [Note] InnoDB: It is also possible that your operating system has corrupted its own file cache and rebooting your computer removes the error. If the corrupt page is an index page. You can also try to fix the corruption by dumping, dropping, and reimporting the corrupt table. You can use CHECK TABLE to scan your table for corruption. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.
2018-03-13T02:24:07.569616Z 0 [ERROR] [FATAL] InnoDB: Aborting because of a corrupt database page in the system tablespace. Or,  there was a failure in tagging the tablespace  as corrupt.
2018-03-13 10:24:07 0x7fa3bcff9700  InnoDB: Assertion failure in thread 140341227263744 in file ut0ut.cc line 942
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
02:24:07 UTC - mysqld got signal 6 ;
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.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.
key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 76385 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x30000
/usr/sbin/mysqld(my_print_stacktrace+0x3b)[0xe8f29b]

在/etc/mysql/mysql.conf.d中写入
[mysqld] 
innodb_force_recovery = 6


然后重启MySQL服务

service MySQL restart


数据库可以读出来,在6的情况下,是无法修改数据库的,也无法插入,只能导出。


然后注释掉刚添加的语句,发现MySQL服务可以启动了。

问题没有找到为什么,还是建议 导出数据后,卸载MySQL重新安装。

Comments (0)