Avatar of Pete Long
Pete LongFlag for United Kingdom of Great Britain and Northern Ireland asked on

WordPress Website MySQL connection Problem

Centos VPS running Mysql 5.1

1 site running perfectly under an SQL account created when the site was built.

Created a new database with a new account and gave the account full privileges. Then installed WordPress and got the cannot connect to database error.

Then I created a new user, and also gave it access to the new database, same issue.

Then tried to use the account that works on the perfectly working site, and then get an issue saying “cannot select database”. Gave a working user account full privileges on new database and then get the “cannot connect to database error”

Logging into the VPS I can connect to MySql and create tables in the database will all users created. It appears to be an issue with the websites or PHP connecting to the databases?
WordPressPHPMySQL Server

Avatar of undefined
Last Comment
Pete Long

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Julian Hansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Pete Long

Returns

http://www.randomjoke.co.uk/contest.php

Testing with legacy MySQL lib ... 
Unable to select database

Open in new window


BUT using the same code in a known good working Wordpress site on the same VPS returns the same error?

I'm using  

define('gb_server', 'localhost');

Open in new window


Is that the problem?

Bear in mind the main wordpress site is up and had been running for  along time this is a new (additional) site on the same server
zippybungle2003

Actually testing the account with new credentials now gives a response time with your script however the WP install still gives a cannot connect to DB error.

Just created another site , non worpdress, that is a basic script that calls a DB, it alsop gets a response however when you try and access the db through the site it fails.

Something strange is going on as PHP appears to log in.
SOLUTION
Julian Hansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
zippybungle2003

I actually found out what was wrong, I believe I had 2 issues....

You are correct that the credentials were wrong, I changed them but it did not works still..

the reason APC cache, even though I had noti installed it for this site it had cached them on this virtual host! simply flushed the cache and away it went...thanks!!

My only issue now is another site I tested has the same issue with just a white screen , however I think that is a PHP issue.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
zippybungle2003

No Pete is a colleagure of mine who asked the question, he is not available now so I im using my account. He will mark it as answered on hiseturn :)
ASKER
Pete Long

Don't Panic! I asked the Question for my colleague :) (he had no Q points left)

You Sorted now Al?

Pete