0

I updated my PHP from 5.4 to 7 and after that my wordpress website cannot connect to the database.

When I put the line define('WP_ALLOW_REPAIR', true); within the wp-config.php and go to address: http://www.address.com/wp-admin/maint/repair.php I still have the same error

Error establishing a database connection

When I connect to my wp-admin, I got the following:

enter image description here

Finally I checked my credential on my database within wp-config.php, they are correct but when I do a mysql> show databases; I got the following:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ChinaXiaoHong
  • 139
  • 1
  • 4
  • 19

1 Answers1

0

please edit wp_config file use this code:

define('WP_ALLOW_REPATR',true); 
rajkumar
  • 61
  • 2
  • 14
  • or fllow this link https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/ – rajkumar Feb 05 '19 at 12:26
  • I did and still same issue. It works perfectly and suddenly cannot connect anymore. I do a testconnection.php and it cannot connect, I checked my config file, no problem there. I then use my 2-days old backup and website works perfectly, I check testconnection works perfectly, config file exactly the same. Then after few days it crash again... – ChinaXiaoHong Feb 13 '19 at 05:41