Skip to content

add support for check unix socket in LudicrousDB::check_tcp_responsiveness() #184

@MahdiAkrami01

Description

@MahdiAkrami01

Problem

some users set skip-networking in my.conf, this setting disables TCP/IP networking for MySQL, allowing only local socket connections (i.e., connections from the same server). It’s useful for securing MySQL in environments where external access isn't necessary.

PHP Warning:  fsockopen(): unable to connect to localhost:3306 (Connection refused)

Disable TCP Check

i try to set $wpdb->check_tcp_responsiveness = false; but after that i got this warning:

[12-Nov-2024 18:10:10 UTC] WordPress database error 2024-11-12 18:10:10 Can't select master__r - 
'referrer' => '..........',
'host' => localhost,
'tcp_responsive' => ,
'lagged_status' => 3 for query SELECT * FROM .........

Solution

Check unix socket instead of $host and $port to fix this warning.

$wpdb->add_database( $master = [
	'host'          => 'localhost:3306:/var/lib/mysql/mysql.sock',
	'user'          => '.....',
	'password'      => '......',
	'name'          => '.......',
	'dataset'       => 'master',
	'read'          => 1,
	'write'         => 1,
	'timeout'       => 0.2,
] );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions