Error Establishing Database Connection hell continues - php

I have created a copy of may wordpress site locally (importing the SQL) and going through one connection bug after the other for days and I'm really almost giving up.
I went through several Database connection errors and now I am on another for which I cannot find an answer in the forums.
I am running the website locally after downloading it and importing the dabase so I have:
define('DB_NAME', 'db_mysitename');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'root');
/** MySQL hostname */
define('DB_HOST', 'local.mysitename');
/** 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', '');
/** debuging mode*/
define( 'WP_DEBUG', true );
define( 'SCRIPT_DEBUG', true );
But when I navigate to local.mysistename/ I get the following:
Warning: mysql_connect(): Unknown MySQL server host 'http' (2) in /Users/me/Sites/mysitename/wp-includes/wp-db.php on line 1141
So I added a database test script in db-test.php
And illogically this works:
wp_commentmeta wp_comments wp_links wp_options wp_postmeta wp_posts wp_term_relationships wp_term_taxonomy wp_terms wp_usermeta wp_users
Why would it work for the test script but not for the website? Any ideas?
Please help.

just put all above information in wp-config.php file at root directory of your wordpress blog
and please change define('DB_HOST', 'local.mysitename') to define('DB_HOST', 'localhost')
it will work

local.mysitename looks like an alias you would have listed in your hosts file, which means an alias for a location that you access over http. You don't generally access databases over http connections, so that looks like it could be the problem. If the database is running on your computer, then you'll want to use localhost or whatever your machine's local IP is.

Related

Error establishing a database connection in my localhost

I am trying to install Wordpress in my localhost Xampp server
But every time I got an error message with
error establishing 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 have already googling but not get the correct answer yet.
I add define( 'WP_ALLOW_REPAIR', true ); in wp-config.php but not solved.......
This means wordpress can't find your database.
Navigate to http://localhost/phpmyadmin. Where it says create new database, choose a name for your database.
Next, open up wp-config.php in the root of your wordpress folder, and update the four values shown below to reflect your new database.
The default credentials for your newly created database are:
DB_NAME: Your chosen db name (case sensitive)
DB_USERNAME: root
DB_PASSWORD: ""
DB_HOST: localhost
/** The name of the database for WordPress */
define('DB_NAME', 'case sensitive chosen db name');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', '');
/** MySQL hostname */
define('DB_HOST', 'localhost');
I have solved my error as below procedure.
While installing Wordpress in localhost, first set some credentials of the file wp-config-sample.php as below
/** The name of the database for WordPress */
define( 'DB_NAME', 'learn_wordpress' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', '' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
and save the file name as wp-config.php and run again localhost/wordpress in the url.
It's done !!

Error establishing database connection in WordPress install

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.

Wordpress installation error: Error establishing a database conection

While trying install wordpress i recieve following error
I use wampserver i have changed wp-config.php file and now it looks like this:
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'root');
/** MySQL hostname */
define('DB_HOST', 'localhost');//i used 127.0.0.1 too but no matter
define('WP_DEBUG', true);
wp-db.php file:
1379 line:
mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
1409 line:
$this->dbh = mysqli_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
but still no result I do not know what to do can anyone help me?
You're trying to use wordpress locally i assume. 127.0.0.1. Then you must have a local database to store wordpress's data. something like WAMP on windows or LAMP on linux. If you already have one of these then you are probably getting an error because your database is not turned on. or you have not edited the wp-config file to include the database the username and password for the database you created. beyond that wordpress does the rest of the work.
You are not very clear of what system you are using, more info would be needed to diagnose your error completely.
so what OS?
what web server are you using? (apache WAMP or LAMP?)
is your database on?
have you edited the wp-config file to include your db info?
The error is pretty straightforward, but could come from a number of different sources.
What that error message means is that you have your setup file misconfigured. WordPress requires a SQL database it can create tables, read, write, and otherwise modify to make and store its content. The configuration you have set in your wp-config.php file is wrong.
Steps to Fix This
Make sure you have an SQL database
Make sure you have a user in your SQL server that can access that database fully and can log in from outside sources
Make sure you know the host, username (for the user previously mentioned), that user's password, and the database name
This is where you enter these into wp-config.php. By default, WordPress only comes with wp-config-example.php so you must set this information in that file, then rename it wp-config.php before navigating to your setup screen.
Also Note: It's possible WordPress cannot access your database because the user you are trying to log in with does not have outside access permissions. Might be worth checking. Also, the host is not always straightforward; if you use Dreamhost or Amazon Web Services, you cannot normally specify localhost as the location of your database server, unless you specifically set your machines to be that way.
WordPress can't...well... "establish a database connection", enable debugging in wp-config.php, this will show more information about the error, it could be a wrong password or server not responding...
Add this line anywhere in the file (like this ).
define('WP_DEBUG', true);
If the line is already there make sure it's true and not false.
answer is :
define('DB_PASSWORD', '');

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