Check this tips if you want to connect to MySQL using the PHP mysqli extension:
- Make sure the mysqli extension is included by using the php -i CLI command or the phpinfo() function in a script accessible through the web.
- Make sure the php.ini setting mysqli.default_socket points to the mysql sock files, usually /var/lib/mysql/mysql.sock
- After making changes to php.ini remember to restart your web server