Issue: iOS Music application either has items listed in the library that will not play; or has an empty library but iTunes reports that music is present on the device and taking up space; or a combination of these issues coupled with the inability to resolve the problem through the standard resolution steps of disabling music syncing to remove all music and then re-enabling or by enabling "manually manage library" and removing the items.
Additionally, attempting to restore from a back-up does not resolve the issue and the default response from the Apple Support Community is to factory restore the device and treat as new device, resulting in loss of all settings and basically starting from scratch.
Cause of issue: Corrupted iOS device iTunes library (MediaLibrary.sqlitedb). This database stores the iTunes Media records and related information such as playcount, lyrics etc. It does not store information and settings regarding iOS Applications as far as I am aware so this should be safe.
- Perform a back-up to your local computer rather than iCloud if practical. This will be quicker in the event of issues.
- Download a iOS device manager such as Phone View (http://www.ecamm.com/mac/phoneview/) which will allow you to directly access the file structure of the device. (This will NOT require an illegal jailbreak to be performed!)
- Enable the Advanced View mode so the entire disk structure is accessible.
- Browse to the following file: iTunes_Control/iTunes/MediaLibrary.sqlitedb
- Rename MediaLibrary.sqlitedb to MediaLibrary.sqlitedb-backup or similar
- Hold down POWER and HOME on your iOS device until the Apple logo appears. Release both buttons.
- When device has rebooted, connect to iTunes and synchronise it.
- iTunes will detect that the Media Library on the device is missing and recreate it based on the items that it has listed in the iTunes synchronisation record for the device.