I am using nginx/1.20.1, PHP 7.2.34, mysqld 8.0.27 on CentOS7. I can open the wordpress index page but the installation always failed. I am sure that my username, password, and hostnames are correct (even if I add more users or reset the passwords), but it says:
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. This could mean your host’s database server is down.
I tried to create my own wp-config.php file and set the configuration, then it would be a HTTP ERROR 500. The log says:
PHP Warning: require_once(/var/www/html/wp-config.php): failed to open stream: Permission denied in /var/www/html/wp-load.php on line 50
I don’t know why mine is line 50 but others are 37. Howeverm, I already change the ownership of html(and even www) folder fo to nginx, and changed all the files in them to 777, but it is still not working.
I think MySQL is not connected to the wordpress but the 3306 port is open:
tcp6 0 0 :::3306 :::* LISTEN 31913/mysqld
and it still did not work when I did:
define( ‘DB_HOST’, ‘127.0.0.1:3306’ );
in wp-config.php
I tired WP-DEBUG but it did not show because of the HTTP ERROR 500. What else can I do now
2
Answers
I read and learned this from somewhere else: Running a test PHP program to connect MySQL
and it returns:
My current PHP does not support the verification method demanded(caching_sha2_password), the default for PHP is mysql_native_password. I altered it with
And it worked.
Are you sure you entered the username and password correctly for the MySQL user?
If you’re still unsure:
Here are instructions for creating a new user and granting permissions