Question

Warning: mysqli_real_connect(): (HY000/2002): Connection refused in /var/www/html/wp-includes/wp-db.php on line 1626

Hi everyone,

I’ve been hunting and searching as much as possible to try to find a solution to this error. It would seem that mysql crashed and did a recovery, and has somewhere along line been corrupted.

I really can’t afford to lose the date, even if it means manually extracting the tables

The error I’m getting is this on the frontend Warning: mysqli_real_connect(): (HY000/2002): Connection refused in /var/www/html/wp-includes/wp-db.php on line 1626

I’ve tried:

  1. Changing localhost to 127.0.0.1 in the config

  2. Restarting and starting mysql - it gives me the error ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

  3. A sysadmin friend tried restoring the InnoDB but no luck. This was in the logs: InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.

Any advice or suggestions is greatly appreciated.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello, I have just started getting this error! Please help! I dont know what to do. Here is whats in my error.log file.

Hope somebody can help!

2020-05-22T09:34:42.958529Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 1009 2020-05-22T09:34:44.417825Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2020-05-22T09:34:44.497428Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: ‘8.0.19’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 MySQL Community Server - GPL. 2020-05-22T09:34:44.723401Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: ‘/var/run/mysqld/mysqlx.sock’ bind-address: ‘::’ port: 33060 2020-07-23T14:07:04.202185Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 22327 2020-07-23T14:07:05.808032Z 0 [System] [MY-010229] [Server] Starting XA crash recovery… 2020-07-23T14:07:05.835217Z 0 [System] [MY-010232] [Server] XA crash recovery finished. 2020-07-23T14:07:06.469263Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2020-07-23T14:07:06.531726Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: ‘8.0.19’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 MySQL Community Server - GPL. 2020-07-23T14:07:06.559668Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: ‘/var/run/mysqld/mysqlx.sock’ bind-address: ‘::’ port: 33060 2020-07-23T14:07:14.076473Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 22467 2020-07-23T14:07:15.224909Z 0 [System] [MY-010229] [Server] Starting XA crash recovery… 2020-07-23T14:07:15.250942Z 0 [System] [MY-010232] [Server] XA crash recovery finished. 2020-07-23T14:07:15.362957Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2020-07-23T14:07:15.447238Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: ‘8.0.19’ socket: ‘/var/run/mysqld/mysqld.sock’ port: 3306 MySQL Community Server - GPL. 2020-07-23T14:07:15.680817Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: ‘/var/run/mysqld/mysqlx.sock’ bind-address: ‘::’ port: 33060 2020-07-23T14:07:25.599697Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 22594 2020-07-23T14:07:25.702059Z 0 [ERROR] [MY-012681] [InnoDB] mmap(137363456 bytes) failed; errno 12 2020-07-23T14:07:25.702237Z 1 [ERROR] [MY-012956] [InnoDB] Cannot allocate memory for the buffer pool 2020-07-23T14:07:25.702330Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error. 2020-07-23T14:07:25.702434Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine 2020-07-23T14:07:25.704229Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. 2020-07-23T14:07:25.704400Z 0 [ERROR] [MY-010119] [Server] Aborting 2020-07-23T14:07:25.707798Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL.

Chiming in with more things to test;

As @bobbyiliev eluded to, ensure that mysqld is in fact running. Check the processlist for an instance of mysqld

ps -ef | grep mysqld\

The results of this may describe the socket file that mysqld is running with. Your error could infact be due to an incorrect value in the client configuration and a quick change here might resolve your problem.

Keep us updated!

BR

Andrew

Hi there @jucanation,

The error that you are seeing means that MySQL is most likely not running. This indeed sounds like an InnoDB issue as you are unable to start the service.

I would recommend first checking your MySQL error log for some more information on what the exact problem could be. If you are using Ubuntu the location of the log file is here:

tail -100 /var/log/mysql/error.log

If indeed it is a problem with InnoDB, you could try starting MySQL in recovery mode, however, I would strongly recommend taking a backup of your before proceeding. The proceeds would differ slightly depending on your operating system, are you running Ubuntu or CentOS?

If this does not work, your final option would be to restore your database from a backup.

Regards, Bobby