XF 2.2 How do I install XenForo without overwriting an existing database?

FTL

Well-known member
My local test installation of XenForo got trashed the other day in the most unlikely and unintentionally comical way. Read about that here for a tickle.

I now want to reinstall it, preserving the MySQL database, but the installer warns that it will overwrite it. I know a little tweak to one of the config files will stop this from happening, instead installing XenForo fresh without overwriting the database

@Brogan I think you posted the answer to this one in of your HOWTOs, but apologies, I can't find it now so would be grateful if you could advise me.

If anyone else can also answer this, I'd be interested to hear your solution too.
 
Last edited:
To prevent a new install from happening, the install-lock.php file must be present in /internal_data folder.
The structure of the file should look like this to function properly:
Code:
<?php header('Location: ../index.php'); /* Installed: Wed, 30 Mar 18 14:31:23 +0000 */
 
UPDATE: Sorry, I'd forgotten that the database got nuked by that other errant application in my article, so it's never going to work. Gonna install it fresh now.



Right, I created the install-lock.php file with your text example. This time browsing to the local website said it was going to do an upgrade (I'm installing the latest 228p1 of course). I let it do it, but it then reported:

1649296779554.png
Deleting this then resulted in this:

1649296695867.png

Note that I do / did have the scheduled content add-on installed, which doesn't seem to like this.

Any ideas?
 
Last edited:
Something is still off here. I installed the test forum clean on my home PC and it's now working. However, the Schemas tab still isn't showing the database name and tables for the forum. It's as if I've got Workbench pointed to a different database, but looking at the connection I can see that it's the right one. I've only got one MySQL installed anyway, so it can't be anything else.

When I look at the one for NerdZone (production version) it shows the correct name of the database and tables.

Any ideas?

1649298863725.webp
 
So, I stepped back through all of this and read the post you made on your site and I'm still lost as to what exactly happened.

The few things that come to mind that may be obvious, but just like flying a plane, it's best to start with a checklist and work through it to solve a problem.

First and foremost, whenever I'm installing something new but have existing data that I don't want to nuke (besides making 1 or 2 isolated backup copies), I make sure to use separate credentials and unique database names. This prevents another installation from overwriting existing data since the db user doesn't access to any other database except the new one (with a unique name) that I've created for the current project.

I saw on your site that you had been using IIS on your home machine, which I've not touched in ages, so I can't really go into specific on the latest IIS versions. However, I do know from past experience that it needs specific configurations for php mapping as well as rewrite settings to properly handle friendly URL's and whatnot. (I think that may have been part of your issue by way of looking at some of your screenshots) The web directory also needs specific permissions for the IUSR_* account (IIRC) in order to read the forum files in the directory.

✅ Database Name - Unique
✅ Database User/Password - Unique
✅ DB/Mysql Permissions Granted to the correct user and database (don't give one user all access to all databased on one mysql instance)
✅ Web Server Configuration Confirmation (IIS, NGINX, Apache, whichever)
✅ Web files uploaded in the correct folder with correct permissions
✅ If rebuilding a broken install, be sure put the correct version+addon back in place to match the database that is pre-existing

If you're trying to restore Xenforo to a previously installed state, the file structure (addons too) has to be put back in place or it'll throw errors like you had shown before. (Database structure/content and files need to match up....etc.)

The only way for an install to get blown up in the database is to use the same database names and credentials, etc.

If you had an existing database (and no backup) that got overwritten by a different product or version, you're in for a hard road to try and recover something like that.

That's all I got, based on reading your posts here and on your site that you linked in the first post. You may have some permission issues going on if things are showing up as they should, posts #3 and #4 kind confused me as to what's going on. If you're trying to install XF fresh, it's really straight forward and all you need to do is use a new, clean database and a fresh XF install pack with a properly configured webserver.
 
Last edited:
  • Like
Reactions: FTL
@ENF thanks for having a proper look at this. No one else seems to be bothered, including Brogan whom I'd tagged and he's supposed to provide tech support, so he's got no excuse.

First of all, the thing to realise is that the installation on my home PC is just a scratchpad, think of a scrap piece of paper that you make temporary notes on and can discard, therefore, I don't make backups of it. The live site of course has backups and they were a prerequisite for me going live with it at the time.

XF had been installed on it even longer than my live site as it's how I learned the ins and outs of IIS and installing and running a forum. I'd upgraded PHP and MySQL a few times too and installed add-ons that I was interested in as part of standard testing to ensure that things didn't break over time.

By default, neither XF nor IC let you know the table prefixes that they're going to use, but I think it's safe to say that they're gonna be different so it should be possible to install IC alongside XF without interference. Yes, I used the same database and root account.

From my article, it looked like IC had nuked the database entirely, however, from this thread, you can see that an existing database on my home PC with XF on it can't be found and that's still a mystery. It could be central to the whole issue of that corruption, maybe.

Anyway, on reinstalling XF, the old XF tables were clearly there since it detected them when I created install-lock.php and it offered to use the existing master account, which I did. However, the "upgrade" process just kept failing once complete, so I think the tables were damaged. Installing it fresh worked fine though and that's where I'm at now. I've not installed any add-ons yet. I now have to try and install IC again to see if it works, or the situation repeats. Note that I've deliberately not upgraded PHP or MySQL from their current, slightly older versions to keep things the same for troubleshooting.
 
By default, neither XF nor IC let you know the table prefixes that they're going to use, but I think it's safe to say that they're gonna be different so it should be possible to install IC alongside XF without interference. Yes, I used the same database and root account.
I don't even trust using prefixes and after years of experience running various platforms, I'm a firm believer in data segregation to the fullest.

@ENF thanks for having a proper look at this.
No worries.

From what I read, my conclusion was that data got intermingled and caused some irreparable damage.

I do remember a case that I worked on back around 2005-2007 where someone had accidentally dropped some important tables (with no backup). However, on a stroke of luck, they had database transaction (Binary) logging turned on and I was able to repair the damage buy rebuilding the database with the transaction logs. (This was vBulletin I believe at the time...)

No one else seems to be bothered, including Brogan whom I'd tagged and he's supposed to provide tech support, so he's got no excuse.
In Brogan's defense, I feel like this is out of his scope of support as far as XF goes. This would wind up in my database support bin.
 
Indeed, if this wasn't a scratchpad, I most certainly would use two separate databases. And when experiments like this go wrong, is where learning happens, too.

Indeed, they were lucky that the tables were replicated in the transaction logs.

If someone's tagged then they should reply, otherwise it's just rude not to and leaves the person (me) hanging. If he doesn't know the answer, then he should say so. I'm not gonna judge him for that. I'm a customer on a business forum asking a reasonable question, not some troll on a hobby forum and shouldn't be treated as such.
 
I should point out that XenForo staff are not obligated to answer questions on the forum - it is for community based support.
Only a ticket will guarantee a response from a member of staff and even then, it is only guaranteed during 9-5 (UK), Monday to Friday.

Having said that, some of us do of course respond to as many posts as we can.

Unfortunately it's not clear what you are trying to do so can you rephrase it?
 
Back
Top Bottom