Error establishing a database connection when setup wordpress
i have create new website to my linode, i try setup my website but i can't pass step 2.Its show error
"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."
but all information is correct. i try log into mysql using SSH by information that i use to enter on setup website, it login successfully. I also try enter in wp-config.php but can't connect.
Anyone can help me solve this error?
@handymovik I'd be happy to help point you in the right direction! I can't be sure which instructions you followed when you set this up, but I will go through some of the instructions we have in our Guide - Install WordPress on Ubuntu 18.04.
You mention that you can't get past step number two. To be certain everything is set up from the beginning of these instructions, you'll want to check that your host name is set to match your domain.
- You will also want to make sure the database service is running. You can check this using the below command to check and see if this service is listening and accepting connections. You will want to check for any mention of
sudo netstat -plunt
and then the below command, if
mysql is not mentioned in that output:
sudo systemctl start mysql
- It may also be helpful to review the information in your MySQL error logs.
sudo cat /var/log/mysql/error.log
- From there, you can check your database permission by logging into the MySQL as the root user. Keep in mind that this user will differ from the root user of your Linode. This is where you will create a WordPress user that will have permissions to access this specific database.
Troubleshooting wp-config.php Access
You mention that you can't connect to your wp-config.php file. If I'm understanding you correctly, this may be a permissions issue. If this is not the case, please, feel free explain what you mean when you say that you can't enter the file.
- The wp-config.php file is created when WordPress is installed. If you are unable to access this file, the permissions for the website directory may need to be changed to set the web server's user as the owner.
sudo chown -R www-data:www-data /var/www/html/example.com/
- After you've gained access to your wp-config.php file, you will want to review the database connection information which is located towards the beginning of the database information.
/** The name of the database for WordPress */ define('DB_NAME', 'database_name'); /** MySQL database username */ define('DB_USER', 'database_username'); /** MySQL database password */ define('DB_PASSWORD', 'database_password');
I hope this information helpful is helpful. Feel free to check out the below official WordPress resources for more information.
Did you set up a root user for MySQL? The WP setup doesn't do this for you and depends on it being done ahead of time. Unless you choose specifically, the ssh login information is not the same for MySQL (or the default).
Do you have port 3306 blocked in your firewall?