• Hello
    I have a compute engine on GCP with httpd 2.4 and php 8.0.30
    On the same GCP project, I created a db mysql 8.0.40.

    And when I want install wordpress, I fill out the forms with dbname, username, host,…
    But after I have an error: Error establishing a database connection.

    I try to connect with client mysql from my compute engine and the connection is successfull.

    I have no logs!

    Could you help me?

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator threadi

    (@threadi)

    I don’t know what GCP is, but maybe the MySQL service is running on a different port there. Check the details you have for the connection again – including the host and the port.

    Thread Starter maxwello62

    (@maxwello62)

    Hello
    The port is 3306, defaut port

    I think their is mysql databse problems

    Thread Starter maxwello62

    (@maxwello62)

    Hello eveyrobdy

    First of all, thank you for your help.
    I enable debug mode and I have this error:

    Warning: mysqli_real_connect(): (HY000/2002): Permission denied in /var/www/html/wordpress/wp-includes/class-wpdb.php on line 1988

    Permission denied

    I have checked all permissions!
    And from my vm, I success to connect to the managed mysql db:

    [root@vm]# mysql -h 10.198.46.64 -u wordpressuser2 -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 119798
    Server version: 8.0.40-google (Google)

    mysql>

    Thread Starter maxwello62

    (@maxwello62)

    here is the line 1988 of class-wpdb.php :
    if ( WP_DEBUG ) {
    mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );

    Thread Starter maxwello62

    (@maxwello62)

    Oh it works!
    When I execute this command: setsebool -P httpd_can_network_connect 1

    Thank you very much

    Mahmoud Agwa

    (@mahmoudagwa901)

    @maxwello62

    The issue is resolved.
    It was caused by SELinux blocking Apache from connecting to external databases.
    The fix was to run:

    setsebool -P httpd_can_network_connect 1
    

    Hopefully this helps anyone who runs into the same issue.
    Let me know if you need any further assistance

    Moderator Support Moderator

    (@moderator)

    @mahmoudagwa901 Please stop using ChatGPT or a similar tool to generate replies. That is not welcome as it is better for forum volunteers such as yourself to use real replies in their own words.

    Hi,
    Add this to your wp_config.php to see what’s going wrong:

    define( ‘WP_DEBUG’, true );
    define( ‘WP_DEBUG_LOG’, true );
    define( ‘WP_DEBUG_DISPLAY’, false );

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Error establishing a database connection when I try to install wordpress’ is closed to new replies.