Resolution:
The problem is related to your moving the mysql.sock file to a new location. PHP needs to know where it is, changing the location will fix the problem and reload apache/httpd (if you are using php-fpm, restart the service)
Easy fix: Edit your php.ini file and make sure you specify the new mysql.sock location.
mysqli.default_socket = /path/to/your/files/mysql.sock
Issue: After moving your datadir for MySQL, WordPress will still not pull up and present the “Error connecting to the database” error.
RELATED ARTICLE(S):
1. Moving mysql datadir in Redhat (don’t forget SELinux!)
2. WordPress troubleshooting