Skip to main content
Help Center
The GoDaddy Community will undergo maintenance starting on Wednesday, July 28th at 3pm PST / 6pm EST. Learn more
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot access new database from within Wordpress (PHP)

I just became a customer with GoDaddy, and have a problem that is working fine with other hosting providers.

I am getting the error:
ERROR: Could not connect. Access denied for user 'Database4321user'@'localhost' (using password: YES)


Here is what i did:

1) Created a database called Database4321

2) Created a user called Database4321user

3) Linked the user to the database with all privileges

4) Created the below script and uploaded it to the root of the website domain/test.php

The script works and is returning: "Accessing database.. Connected!"

5) Now going in to Wordpress and adding the same code as a code snippet (i am using the plugin Insert PHP Code Snippet). Running domain/test/

Now i get the error: ERROR: Could not connect. Access denied for user 'Database4321user'@'localhost' (using password: YES)


The script:


Echo "Accessing database..<br>";

define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'Database4321user');
define('DB_PASSWORD', '12345');
define('DB_NAME', 'Database4321');

$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
} else {
	echo "Connected!";

Why is it different under Wordpress? I have the exact same setup on two other hosting providers, and it works.

There is something here at the GoDaddy setup that makes me unable to do this. I have tried to contact support, but they are unwilling to assist, they say its a Wordpress problem which they do not support.


I hope somebody can help me out here, as i have just signed up for a whole year and cannot use the services as it is.

Thanks in advance.





** UPDATE **

To test i added a table inside the Wordpress database, and this way it works.
So it seems that running a PHP file inside Wordpress will not let me access a different database than the one WP is installed on.
But i still want to access a different database, and credentials/priviledges seems to be in order.


Community Manager

Hi @Charliep. Thanks for being part of GoDaddy Community! It sounds like something within your WordPress install. I'd double check to make sure that your WordPress configuration in the GoDaddy hosting is exactly the same as the one you had with your other hosting provider, including version. I'm not sure if it will help, but I did find this 3rd party article that seems to be talking about the same thing. 


JesseW - GoDaddy | Community Manager | 24/7 support available at | Remember to choose a solution and give likes.