MySql databases corrupted after upgrade? - mysql

I have been dealing with this issue for a while now. For some reason, when i went to run a Ubuntu upgrade, MySql-server upgrade failed. This was on about 8/10. This had happened before due to a "DATADIR" link (won't go into detail on that just now). I went through hell trying to get the package to upgrade and eventually got the package to upgrade by creating a new MySql database structure (after moving mine somewhere else). Once I did that (with some steps involved) the package upgrade completed.
Then, when I tried to replace the "new" databases with my old onse, it wouldn't start the service. I came to find out that the "Mmysql" (system) database folder was just completely gone.
So, I took the "new" database and overlayed it on my "old" database files. This got me in! Of course, old users, and anything else in the system database, was gone. So I started to rebuild them.
The problem occurred when i tried to go into some old databases. About half of them report that the table does not exist when trying to load them. Mostly, it is all of the tables in particular database, but there are a few databases where some tables "don't exist" and others do.
The thing is that the tables do exist. I believe they are simply corrupt.
So, I'm really trying here, but I can't seem to figure out how to get all of the tables to load. I have a backup from the 13th, presumably after the upgrade failed but before I really started messing with things. I'm going to try to use that, but if anyone knows how/why some tables are corrupted all of a sudden and why others are not and especially if someone knows how to fix this, that would be absolutely wonderful.
Unfortunately, my regular backups haven't been working for months, and the latest backup I currently have access to is 2 years old. Quite a bit has changed in the database since then, but as a last ditch effort, I may try to import that data and use "mysql_upgrade" to restore this, then overlay any new databases I have created since then into the directory structure and see if they import that way.
Thanks for any suggestions you may offer.
--mobrien

I believe this was due to a permissions issue that had some files locked and when I fixed the perm issue, the tables that were accessible were corrupted. I restored the same backup again and this time it worked. The only folder that was missing was the "mysql" folder, and for that I recreated a new one, then patched it in, then created new user permissions for the existing tables. This was working, but then I ran into another issue, so I will open a new questions for that. This has been a nightmare and the moral of the story is: keep better backups and test them!

Related

How to properly Update Docker Azerothcore with customizations to both code (scripts), modules and database (added quests, vendors, items)

I'm running Azerothcore-WOLTK inside a Docker container.
I would like to update the server since I read there's an important security fix.
However I never updated the server since I first installed it last year (December 2019). Since then, I have customized the server in several ways:
I have customized a few boss scripts to work properly with two players.
I have installed a few modules, including one that also required some extra code to be compiled, and some SQL queries to be run.
I have modified the database myself, adding Quests, NPC, Vendors and Items
As such, I'm extremely concerned I would end up messing everything up. I would require your assistance on how to proceed to update the server to the latest version while maintaining all the customization I have performed.
I'm especially concerned about the database changes as I figure I could backup the updated boss scripts, do a git pull and replace them again before building (I should do a fork afterwards, I didn't think about it)...
But in any I case I would be extremely thankful if you could guide me step by step along the way, considering I am using a docker installation.
For anything Database related I use Heidi SQL, so I could use that for any Database procedure. I'm not very proficient in SQL queries, but I should be able to import .sql files as needed.
I realize I'm asking a lot, so please don't feel pressured to answer right away. I will be most thankful if you could help me whenever you have the chance.
Thank you for your time :)
I'll try to answer all points you mentioned:
1. The boss scripts.
The worst thing that can happen is that you get merge conflicts while pulling the latest changes using git. So you would have to manually solve them. It's not necessarily difficult, especially in your case. It's just boss scripts, so by nature, they are quite self-contained and you are sure to not break anything else when messing with them.
2. Modules
The modules should not be a problem at all. Modules exist exactly for this reason: being isolated and not causing issues in case of updating the core or similar.
My only concern here would be that module that required a core change. I don't know what module you installed, normally this shouldn't happen. A proper AzerothCore module should not require any core change.
However, again, the worst thing you can have is some git merge conflicts, nothing too big I hope (depends on how big and invasive were these changes required by the module).
3. Custom database changes.
The golden rule is: always store your custom SQL queries somewhere, in a way that they can be easily re-applied. For example, always use DELETE before INSERT, prefer UPDATE when possible, etc...
So all you need to have is a file (or a bunch of files) containing all your SQL code corresponding to the custom changes you made. If you don't have it, you can still extract it from your DB.
Then you can always re-apply them after you update your core, if you feel it's needed. It might also be the case that you don't need to re-apply them at all. Or maybe you want to start from a fresh AzerothCore world database and re-apply your changes. This really depends on the specific case, but anyway you will be fine (as long as you keep your changes in SQL files).
You can use Keira3 to edit your database, or just extract your changes in case you need to. For example, you can open an entity and copy its "full query".
Backup first
Before starting the upgrade procedure, create a backup of:
your DB
the source files that you have modified (e.g. bosses, etc...)
Update frequently!
However I never updated the server since I first installed it last year (December 2019).
This is not recommended at all! You are supposed to update your AzerothCore frequently (at least once a week). There are a lot of good reasons to do so, one of them is: it's way easier if you do it often.
How to update AzerothCore when using Docker
A generic question about updating AC with Docker has been asked already here: How to update azerothcore-wotlk docker container

Big problems with shared SugarCRM database

Here is my situation:
I have two hosting sites with a domain each, each with Sugarcrm infrastructure. I started with one hosting site and started creating a database through Sugar. Then, I started a SECOND hosting site with a new domain, and I believe I have linked the two databases accidentally. If I change a value in the database on one site, it gets reflected on the other.
So, the original domain/hosting site is expiring, and I would like to move the SQL database over to the new site permanently. I have made a backup of the database from the original site and have it on my desktop.
My questions:
1. Can I just drag the SQL file into the new site (I use FileZilla) database location and everything will be OK?
2. I cannot find the location in file manager of the new site where I would drag this database into!? I use goddady, and the newer site uses cpanel.
**Other problem: I have accidentally upgraded the newer sites SugarCrm version, and have created huge problems because the original site is not upgraded, and the sites do not like that very much as the database is shared. There original site is unreachable (it says you cannot use the newer version database with the old Sugar version), and the new site has visible problems but is workable.
As you can tell, I am a totally inexperienced n00b, and am learning as I go. I have spent weeks setting up this database, and would appreciate any help on maintaining its integrity.
Thank you very much!
Tom
I'm assuming you're using MySQL for your database.
Unless your tables are all MyISAM tables, simply copying the database files won't work.
Whenever you want to move a MySQL database it's a good idea to dump the database, move that file over, then recreate the database. Read up on the mysqldump command.
If you're using Oracle or something else, I would think a similar technique would be desirable. Basically dump your database to a backup format that your database server can use to recreate your database. Don't just copy database files around.

Joomla 2.5 core installation database problems

I'm in quite a bit of a bind. I've got a copy of joomla 2.5 that I've been working with as a test environment for a site redesign. However, there was an issue, and one of the developers on my team "accidentally" (don't even get me started, here) deleted a row in one of the databases for the installation. Now, all of the content edit screens are essentially broken.
I have NO IDEA what specifically was deleted nor do I know from what table, and we don't have a workable backup from before this screw up.
From the front end, nothing at all appears amiss (every page with every bit of content is just fine), so it was definitely a core installation database row that was deleted.
Is there any (free) solution that anyone could suggest to remedy this situation? Would it be possible to simply copy the existing content from the database to a fresh installation, along with the core files (if so, could someone shed some light as to which tables we should be copying to the fresh installation)?
I think there is no solution to remedy your situation, But i guess you could do it by hand by following these steps:
Transfer all new contents table to the new installation.
Keep attention for Joomla tables like (#_extensions, #_assets, #__schema ...).
Try to merge between the old Joomla tables and new one.

Keeping a database structure up to date in a project where code is on subversion?

I have been working with Subversion for a while now, and it's been incredible for the management of my projects, and even to help managing the deployment to several different servers, but there is just the one thing that still annoys me. Whenever I make any changes to the database structure, I need to update every server manually, I have to keep track of any changes I made, and because some of my servers run branches of the project (modifications that are still being worked on, or were made for different purposes), it's a bit awkward.
Until now, I've been using a "database.sql" file, which is a dump of the database structure for a specific revision. But it just seems like such a bad way to manage this.
And I was wondering, how does everyone else manage their MySQL databases when they're working on a project and using Subversion?
In my team here is what we currently do:
we only have one branch: the trunk, which is where every developer checked in his changes.
When we want to release a new version of our solution, we create a new branch from the trunk. (after stabilizing it a bit).
For each release, we also have a file to migrate the schema of our databases from version n-1 to version n. We also have a script to rollback from n to n-1. So when we start a new release, we create new migration & rollback files which are comitted in the trunk.
Thus we are able to rebuild the database corresponding to any version of our solution starting from any "version" of a given schema.
Actually, we also had a lot of debates on this question and this is finally what we chose to do. But if you guys have some ideas to help us to improve, let us know :)
Liquibase might be something useful for you.
I've played around with this quite a bit, although not to the point of using it in anger.
Basically you define your database and scripts in their syntax, and they generate upgrade and from-scratch scripts for various databases for you.
Takes a bit of getting used to, but works quite well.

What would lead to an "Unknown object in backup file" problem when restoring a backup of a MySQL database?

Unfortunately, the problem is not more specific than that. I've found a few examples of people reporting similar problems by doing a Google search, but I can't find the part of the restore that is actually causing the problem, which might help me track it down on my own.
Suggestions for either resolving this problem or being able to track down the root cause would be appreciated.
There's one bug logged at bugs.mysql.com that references the error you describe:
"Bug #37253 Unable to restore backup file containing BLOBs"
The solution described in that bug is to increase the max_allowed_packet in the MySQL server configuration. The user confirmed that raising the value to 100M allowed him to restore his database.
ANOTHER FIX
I also had this problem! The answers online didn't seem to help (max_allowed_packet and others)
Here's what fixed mine:
Instead of running the Restore function, I imported through MySQL Migration Toolkit (installed with GUI Tools on Windows).
The Migration Toolkit also failed, but had descriptive errors in the Log on the final page. In my case, it was a few incorrect Date fields in my data (usually "0000-00-00") that wouldn't migrate correctly.
Fixing these dates in my tables solved the Restore problem.
Hope this helps somebody else out there.
I have had something similar in the past- it has something to do with how it was backed up. I think some applications put invalid comments in the backup files which cause errors.
My suggestion- if you are stuck trying to restore those files- is to incrementally start backing up from sections of the backup file and find what is causing the problems- which from what I recall the case for me was that they were some text in the file that was inconsequential to remove.