php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81055 $mysqli->real_connect connecting to socket exception
Submitted: 2021-05-19 18:09 UTC Modified: 2023-01-10 17:15 UTC
From: ivsucic at fesb dot hr Assigned:
Status: Open Package: MySQLi related
PHP Version: 7.4Git-2021-05-19 (Git) OS: wsl2 debian
Private report: No CVE-ID: None
 [2021-05-19 18:09 UTC] ivsucic at fesb dot hr
Description:
------------
When connecting to a mysql db with mysqli->real_connect using unix socket it gives an exception unexpected server response while doing caching_sha2 auth. The user of apache2 is changed as needed.

Test script:
---------------
$mysqli->real_connect(null, 'ivan', 'ivan', 'phpmyadmin', 0, '/var/run/mysqld/mysqld.sock');

Expected result:
----------------
Establishing a connection to db

Actual result:
--------------
Exception unexpected server response while doing caching_sha2 auth

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-21 14:00 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-05-21 14:00 UTC] cmb@php.net
Are both client and server running on WSL2?
What is your Client API library version (see phpinfo)?
Can you connect via mysqli?
What's your server version?
 [2021-05-21 15:45 UTC] ivsucic at fesb dot hr
-Status: Feedback +Status: Assigned
 [2021-05-21 15:45 UTC] ivsucic at fesb dot hr
Are both client and server running on WSL2?
Yes, both are running on wsl2.
What is your Client API library version (see phpinfo)?
mysqlnd 7.4.15
Can you connect via mysqli?
Using phpmyadmin with password authentication works.
What's your server version?
Apache 2.0 Handler
 [2021-05-21 16:00 UTC] cmb@php.net
-Status: Assigned +Status: Feedback
 [2021-05-21 16:00 UTC] cmb@php.net
Thanks for the info!  With "server version" I meant the version of
MySQL (if it's even MySQL and not MariaDB or such).

Anyhow, if you can connect with phpmyadmin, the MySQL server is
probably irrelevant.  Maybe there are issues with unix sockets
under WSL2?  Can you connect via TCP/IP with mysqli?
 [2021-05-21 20:50 UTC] ivsucic at fesb dot hr
-Status: Feedback +Status: Assigned
 [2021-05-21 20:50 UTC] ivsucic at fesb dot hr
I am using mysql 8. I can connect via tcp/ip
 [2021-05-22 21:33 UTC] cmb@php.net
-Status: Assigned +Status: Open -Assigned To: cmb +Assigned To:
 [2021-05-22 21:33 UTC] cmb@php.net
Thanks for providing further info!

I'll leave this ticket for someone else more used to connecting to
a MySQL server via Unix sockets.
 [2022-12-14 08:45 UTC] Redick121ouise at gmail dot com
Object-oriented style

public mysqli::real_connect(
    string $host = ?,
    string $username = ?,
    string $passwd = ?,
    string $dbname = ?,
    int $port = ?,
    string $socket = ?,
    int $flags = ?
): bool
Procedural style

mysqli_real_connect(
    mysqli $link,
    string $host = ?,
    string $username = ?,
    string $passwd = ?,
    string $dbname = ?,
    int $port = ?,
    string $socket = ?,
    int $flags = ?
): bool

Thanks, (https://www.aetnamedicare.us/)github.com
 [2023-01-10 17:15 UTC] dharman@php.net
-Package: MySQL related +Package: MySQLi related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC