• i am currently installing my web server on OpenBSD 7.3 using nginx, php, and MariaDB. i finished the installation by checking myserveripaddress/test.php then i proceed to install wordpress. when i open my fresh wordpress installation, it gave me an error “Your PHP installation appears to be missing the MySQL extension which is required by WordPress” so i uncomment the the “extension=mysqli” and extension=pdo_mysql on php-7.4.ini and the error is gone, now when i went to myserveripaddress/wp-admin/setup-config.php and input my database name, user name, password, and host it gave me an error “Error establishing a database connection”.

    i double check atabase name, user name, password, and host and it is correct and mysqld is running. i check the installed package and all present as seen a below:

    mariadb-client-10.9.4v1 multithreaded SQL database (client)

    mariadb-server-10.9.4v1 multithreaded SQL database (server)3

    nginx-1.22.0p0 robust and small HTTP server and mail proxy server

    pecl74-imagick-3.7.0p1 PHP support for the ImageMagick library

    pecl74-redis-5.3.7p0 PHP interface to redis

    php-7.4.33 server-side HTML-embedded scripting language

    php-gd-7.4.33 image manipulation extensions for php

    php-imap-7.4.33 imap, pop3 and nntp extensions for php

    php-intl-7.4.33 intl library support for php

    php-mysqli-7.4.33 mysql database access extensions for php

    php-pdo_mysql-7.4.33 PDO mysql database access extensions for php

    php-soap-7.4.33 SOAP functions for php

    php-xmlrpc-7.4.33 XML RPC functions for php

    php-zip-7.4.33 zip functions for php

    when i tried doas netstat -an | grep LISTEN | grep 3306 it gave me this

    tcp 0 0 127.0.0.1.3306 . LISTEN

    tcp6 0 0 ::1.3306 . LISTEN

    when i tried to telnet localhost 3306 it give me this:

    telnet localhost 3306

    Trying 127.0.0.1…

    Connected to localhost.

    Escape character is ‘^]’.

    X

    5.5.5-10.9.4-MariaDBDyV”Clu)?fJ}Y#Cg\xes4mysql_native_passwordConnection closed by foreign host.

    here my test.php code

    <?php
    $servername = "127.0.0.1";
    $user = "myuser";
    $pass = "mypassword";
    // Create connection to MariaDB
    $conn = new mysqli($servername, $user, $pass);
    // Test connection to MariaDB
    if ($conn->connect_error) {
    die("Database Connection failed: " . $conn->connect_error);
    }
    echo "Database connected successfully, Congratulations ";
    ?>

    and give me this “Database connected successfully, Congratulations”

    how to fix the “Error establishing a database connection”?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @lazuardinsani

    Thanks for the detailed question. As your testing indicates, it appears your database is up and running. That might point to the database credentials, entered when initially installing WordPress, being incorrect.

    Have you double-checked that the database credentials in wp-config.php match those in your successful connection test?

    Another option to get further debug information would be to check the MySQL server logs for error messages. I believe in OpenBSD with MariaDB, they are normally located in /var/log/ but don’t quote me on that.

    I hope that helps!

    Thread Starter lazuardinsani

    (@lazuardinsani)

    i solve it by changing the host from localhost to 127.0.0.1, thankyou for the answer

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress Error: Error establishing a database connection’ is closed to new replies.