XF 2.2 Trouble connecting to database

ibrian

Well-known member
I've moved an account to a new server and am having problems getting XF to connect to the database. The database name, db username, and password, all appear to be correct in Cpanel (the new account has the same exact account name as the previous server account).

I also had problems with a WordPress frontend install not working, but I found that the config file was calling up a specified database address for the old server rather than localhost.

The same applied for the XF config file so I changed that, but I'm still not sure what the connection issue is.

I did email support, but Paul replied and said this is nothing to do with Xenforo, because if you move a Xenforo install between servers then Xenforo wash their hands of you. Which I think is pretty poor support really, so I'm having to ask on the forums now instead.
 
Is the DB on the same server as the web/XF? Do you have console/ssh access to the server to check/test DB conectivity? What about cpanel web tool to the DB, does it reveal settings/config? If the DB is not on the same server, eg. then your server vendor should be able to help with DB connectivity issues.
 
Are you sure the db name and user are exactly the same? In my experience, it adds a prefix to the new user and db which then you need to add that prefix to the imported db and user config file.

It's usually your login user as prefix.

Example, your cPanel username is user123. When you create a database named forumdb, cPanel will actually name it user123_forumdb. Similarly, if you create a MySQL user named forumuser, cPanel will name it user123_forumuser.

When you import the db you'll see a different prefix: newserver_user123_forumdb and newserver_user123_forumuser while your config still says user123_forumuser.
 
It's okay, I managed to fix it by doing a completely fresh reinstall. I'm guessing the database URL had been set up as a value in the database somewhere, instead of just using localhost, FWIW.
 
Back
Top Bottom