• Resolved GeddeDev

    (@ggedde)


    If I manually set DB_HOST with “localhost:/run/mysql/mysqld.sock” then it works, but on a new installation if I use the same host in the WP Installer it does not work.

    Error establishing a database connection
    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost:/run/mysql/mysqld.sock. This could mean your host’s database server is down.

    So it seems that the WP Installer needs to be updated to allow for mysql sockets in the Database Host.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Dion

    (@diondesigns)

    PHP assumes the location of the MySQL socket file is /var/lib/mysql/mysql.sock. Since yours is different, you must tell PHP its location. Add the following line to your php.ini file and restart PHP:

    mysqli.default_socket = "/run/mysql/mysqld.sock"
    

    PHP applications using mysqli will then correctly recognize localhost as the database host.

    Thread Starter GeddeDev

    (@ggedde)

    Thanks Dion Designs, I will take a look. I figured when using mysqli_connect that passing the socket path would also tell PHP to use that path. I think that PHP setting is only if you don’t specify a socket as it is labeled “default”, but I am specifying one. I will still give it a try though.

    I am using PHP-FPM and prefer to do all changes in the FPM Pool file so I will try that first and let you know if that makes a difference.

    • This reply was modified 5 years, 9 months ago by GeddeDev.
    Thread Starter GeddeDev

    (@ggedde)

    Ok, I got it working. It had nothing to do with my php settings.

    Instead of using
    localhost:/run/mysql/mysqld.sock

    I had to remove the localhost and just use
    :/run/mysql/mysqld.sock

    Notice you must keep the : at the front.
    This might be because I have networking disabled in my mysql config.

    I tested the WP Installer again and the installer worked!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP Installer doesn’t work with Mysql Socket’ is closed to new replies.