Error establishing database connection in WordPress install - php

I am working with a managed server from 1&1 and I am trying to manually install WordPress with no luck. I went and downloaded the WP core files, uploaded them via FTP and then went into mySQL and created the database and username/password etc. and assigned the privileges. When I try to install wordpress via "www.example.com/wp-admin/install.php", I continuously receive the error:
Error establishing a database connection
I tried everything and triple checked my user,password, etc.
Here is my credentials (Password is hidden):

// ** MySQL settings ** //
/** The name of the database for WordPress */
define('DB_NAME', 'yourdb');
/** MySQL database username */
define('DB_USER', 'yourdb user');
/** MySQL database password */
define('DB_PASSWORD', 'yourpassword');
/** MySQL hostname */
define('DB_HOST', 'hostname');
Host name is always a localhost. for check your database credential is correct or not please feel a wrong value # let me know I am here

Try use 127.0.0.1 instead of localhost as the db host. Had the same issue and this fixed it for me.

Related

What we need to put in wp_config.php?

I tried uploading a wordpress site and I arrived to the step when I need to modify wp-config.php
Here's the code.
define('DB_NAME', 'replace_with_database_name_you_noted_down');
/** MySQL database username */
define('DB_USER', 'replace_with_new_host_mysql_user_name');
/** MySQL database password */
define('DB_PASSWORD', 'replace_with_new_host_mysql_password');
/** MySQL hostname */
define('DB_HOST', 'replace_with_new_mysql_host'
I don't understand what means "replace with new mysql host", because I have the files in wordpress directory and when I try to access the page, it returns "403 forbidden.The access for the server was
denied".
I mention that i tried that on a simple installation wordpress site, I cannot upload my site on cpanel, can you send me a tutorial and give me some suggestions please ?
In order to work wordpress need a sql database. You need to create one and a user with a password.
If you have cpanel you can install directly wordpress with one click with softaculous or other. This will create a database automaticaly and fill the wp-config for you.
If you install wordpress "manually", you have to fill the wp-config yourself. For MySQL hostname, you can try localhost (if the sql database and ftp hosting is at the same place)

404 Database error on MAMP WordPress install

I am struggling to finish the local installation of Wordpress on MAC. I used MAMP and migrated all the files successfully: database on PhpAdmin and wp-config.php & wp-content.php via FileZilla. I get a database connection issue when trying to access the site.
I followed the instructions of this guy:
https://hsnyc.co/how-to-transfer-a-live-wordpress-website-to-your-localhost-manually/
except that I use MAMP and the localhost is Macintosh> Applications>MAMP>htdocs (The Database is under htdocs)
Tools used on a MAC Book Pro:
MAMP
PhpAdmin
FileZilla
Interconnect It
Wordpress
The PHP version used is 7.0.0.
Note: the Database name Is made of capital and small letters no space.
I changed the Database credentials in wp.config.php to the below:
define('WP_HOME','http://localhost/DataBaseName');
define('WP_SITEURL','http://localhost/ DataBaseName ');
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'DataBaseName');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'root');
/** MySQL hostname */
define('DB_HOST', 'localhost');
I also get a 404 error message when clicking on "localhost:3306" tab in PhpAdmin.
Solutions tried:
I reviewed the DataBase credentials
I tried changing the Localhost to "localhost:3306", " 127.0.0.1", " 127.0.0.1:3306".
Note: at first, I entered the wrong database name and got a message that the database couldn't be found.

EasyPHP - Taking WordPress live to localhost

I have been giving a task for a client to take their existing word press database and make changes to the client specifications. However I do not want to edit this database on their live website so I am trying to pull it from their server and work on it locally.
The problem I am having is that I managed to drag all the files successfully from their host and put them onto my localhost, however when I try to view it locally I get the error: "Error establishing a database connection"
As they can't give me their database to work locally on, I am in the position where I have their files locally on my machine but I am trying to access their live database.
So when I pulled the files down locally, I expected that my local machine will just connect to their live database automatically.
In the wp-config.php file I have the settings:
define('DB_NAME', '');
/** MySQL database username */
define('DB_USER', '');
/** MySQL database password */
define('DB_PASSWORD', '');
/** MySQL hostname */
define('DB_HOST', 'localhost');
Removed the db_name, username and password
The line I am looking at is 'localhost', would this need to be changed to their host? Because from what this says is that it will check the localhost on my local machine for the database which I do not have.
However on the server it would say check the localhost on the server which would be there?
So to sum this up, to get this working correctly, would I either need:
The database to export to my local machine
The IP / Hostname of where the database is stored?
Also is it possible to find out what this is without directly contacting the client as I doubt they will know this.
Cheers
I managed to get the IP they were using by pinging the live website through the command line.

wordpress on xampp database error

Hi I am trying to install worpress on xampp to design and test my blog on but when I go to localhost/wordpress it keeps telling me that
"Error establishing a database connection"
Please help been trying everything.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', '');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
I am running it on Windows XP
Try create Wordpress database on your MySQL server
The error message would suggest that the details you have in your code sample are incorrect.
Do you have a 'wordpress' table?
Can you log into phpMyAdmin using the XAMPP suite using the account 'root' without a password?
You may need to setup a new user account with a password and grant the relevant privileges and then re-install Wordpress.

Installing wordpress on OS X error establishing connection

I am really confused by the wordpress installation. The wp_config file has the root username and password for my instance of mysql (localhost) and I have created a blank database called 'wordpress' (I am not sure whether I am supposed to have a database created to begin with).
When I go to http://localhost/wordpress/ I get an 'Error establishing a database connection' message. Am I suppose to have a database called 'wordpress' to begin with?
These are my credentials from the config file:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'friday');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
See http://techtrouts.com/mac-mysql-does-not-connect-on-localhost-but-connects-on-127001/
for some information on this.
Basically, on a default installation on a Mac you have to connect to 127.0.0.1 instead of localhost. So if you change the following it should work.
/** MySQL hostname */
define('DB_HOST', '127.0.0.1');
With Wordpress you should have a database setup already (no tables, just the database).
So the first option should be the database name. If you're on shared hosting there might be a prefix before the database name.
Then the user of the database (which should be set up when setting up the database).
Then the password of that user.
Then, finally, the host is usually localhost, but if you're on shared hosting it could be different. You'd have to check your hosting providers docs to be sure.
Also, the first place you should go to is: http://localhost/wordpress/wp-admin/install.php

Categories