Question

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

Posted May 15, 2020 625 views
MySQLWordPress

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: mysqlirealconnect(): (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.

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.

×
2 answers

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

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

Submit an Answer