0

I am getting the error: Error establishing a database connection. I go to localhost, and it brings up the wampserver homepage (I am using wamp obviously) I click on my project which is called wordpress-first and it just says this site cant be reached. if I go to localhost/wordpress-first it gives me the error establishing a database connection. I documented every step I took because I had a feeling I was going to have an issue. So here is the steps that I took installing WAMP, wordpress and filezilla.

downloading wamp


• Download wampserver from wampserver.com/en/
• Following this video: https://www.youtube.com/watch?v=StfQetPz2og&t=9s

• Downloaded wampserver.3.1.3.exe and the read me and pdf of how to install.
• Moved the exe. File into my c drive
• Moved readables into a folder in documents
• Installed the exe. For wamp in c drive
• I changed the default browser from IE to chrome upon setup
• Notepad was chosen as the text editor
Mysql5.7.21 was installed

Once installed I clicked on the wampserver desktop icon. The command prompt opened and then closed immediately. I went to the bottom right of my screen and clicked on the W icon in the notifications section where the volume control is. I clicked into the wamp icon. I clicked start and services and it started PHP Apache and all that. I went to localhost and opened the WAMP homepage.
• Click on phpMyAdmin to create a database
As a default the username is root and there is not password. Just leave it blank to begin with.
• Click on databases
• Go to create database. Name it whatever you want. I named it wordpress_first.
• I clicked create and a prompt appeared telling me the database has been created.

downloading wordpress


• I downloaded the wordpress 4.9.8 zip file.
• I extracted the files in my downloads folder.
• Then move your wordpress folder in the wamp folder so in c / wamp / www
• Next, I renamed the file from wordpress 4.9.8 to wordpress-first, the name of my database
• I went into the wordpress-first folder and found the wp-config-sample.php file. I made a copy of this file in the same folder and renamed it as wp-config.php
• I opened this file in atom
• There are functions in this file that look like this define(‘DB_NAME,”database-name-here”);
• I changed the second parameter in database name to wordpress-first
• I changed the second parameter in user name to root
• I changed the second parameter in password to “” for no password
• You can now see the new-folder on the WAMPSERVER homepage in localhost/ and it is called wordrpess-first
I clicked on the folder in localhost and got the error This site can’t be reached wordpress-first’s server IP address could not be found. If I type in localhost/wordpress-first it gives the error Error establishing a database connection
• Went to this site for help https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-error-establishing-a-database-connection-in-wordpress/
• Theres a video that said to go into your wp-config file and after the line thats all stop editing! Happy blogging. – add this line of code: define(‘WP_ALLOW_REPAIR’,true );<br> • This didnt work, another thing they said was that I need an FTP client and that WAMP doesn’t come packaged with this. So I went to this site.
https://www.betterhostreview.com/setup-filezilla-ftp-server-wamp.html where they have a tutorial on downloading filezilla, an FTP client for windows.

Filezilla

  • During the filezilla installation process:

• There was a prompt for the port number and I clicked on the default one that popped up which was 14147.
It then said error: Connection to server lost… You appear to be behind a NAT router. Please configure the passive mode settings and forward a range of ports in your router. Warning: FTP over TLS is not enabled. users cannot securely log in.

I don`t know what to do at this point so if anyone has any suggestions I would appreciate it thanks!

  • Better you try deleting wp-config.php and open your wordpress site. – Balas Aug 13 '18 at 3:57
0

If everything is normal ( i.e., web server is working, ) you should care for only following things when creating new wordpress site.

define('DB_NAME', 'db_name');

/** MySQL database username */
define('DB_USER', 'user_name');

/** MySQL database password */
define('DB_PASSWORD', 'db_password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

db_name : name of the database that will hold your wordpress site's content

db_user_name: It's good idea to create user for accessing that particular database only ( restrain other databases access i.e., if you use root for the user name )

password: this is the password for database ( not the password used to log into phpmyadmin or any other database dashboard )

localhost: name of the database server

another thing to note is

$table_prefix  = 'wp_';

This will normally won't matter that much but in case you want your database to have some other prefix than wp_ make suer you update above value in wp-config.php file.

Other things like read/write/execute, these are privileges on any file/directory on UNIX like system. These need to be set properly as well but you are using WAMP, so you don't have to worry about these for now.

.htaccess is generally automatically created for each site.

If you have set these things correctly, it should work.

If not, consult this problem with your hosting support.

Good day!!!

  • thanks, I checked again and the username, password and host are definitely correct.. maybe I`ll just have to get with hosting support like you suggested. – CyanMagentaYellowBlack Aug 13 '18 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.