Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just ran into an OS issue, and I was thinking of simply doing a reinstall of Ubuntu. I was looking at the Ubuntu installation options, and I saw that I could "Reinstall Ubuntu 13.04". "Documents, music..... Installed software will be kept where possible. System-wide settings will be cleared."

Originally, I was using this linuxbox for a Wordpress installation, it had the LAMP stack installed. Will MySQL and PHP be kept? Also, will I be able to reinstall without damaging/wiping out the database for Wordpress? Those are the two biggest concerns on my mind right now, and as a Linux noob, I'm really hoping I don't lose those two.

share|improve this question
For many aspects, it is better to determine problem and solve it without reinstallation. No one could guarantee that your settings will be kept since we don't know where they are. – Danatela Jul 23 '13 at 4:13
Your database is stored at /var/lib/mysql/ and you should make a backup of your /var/www directory as well, which would also be deleted on a re-install. – Abhay Rana Jul 23 '13 at 4:38
I see. A problem I've been facing is that when I boot into LiveUSB, I can mount the partition that is supposed to have /var, but when I cd into /var, the directory is empty. However, when I open up the partition in Ubuntu's file explorer, I can see /www. Is there any reason why this is the case? – ericmjl Jul 23 '13 at 6:15
up vote 1 down vote accepted

Your databases will be lost if you reinstall Ubuntu.

If you want to have a .sql file that you can directly import into any system, you can do the following command: mysqldump -u root -p --all-databases > ~/mysql-backup.sql. It will prompt you for the MySQL root (administrative) user password, then dump all the SQL data into the file at /home/USER/mysql-backup.sql (where USER is the user you've logged into)

That file, then, can be used to restore all your database data, so make sure you download it somewhere other than your server. Then, upload that file to the new server in your home directorywhen you want to restore the data, do: mysql -u root -p < ~/mysql-backup.sql

That will restore all your database data and your files.

Remember to back up your website data if the databases are part of a website, and also remember to back up (or download to a place on your computer but not at wherever you're reinstalling) any data you want to keep, as well.

share|improve this answer

All files and directories in /var/www will be deleted when you reinstall Ubuntu, so you better create a back up of all necessary files, not forgetting your databases if you have one.

share|improve this answer
The files in var/www won't be lost if the files are on a separate partition and if the partition isn't selected for formatting during the install. – papukaija Jul 25 '13 at 15:56
@papukaija judging solely by the OP's statement of " ... , and as a Linux noob, ..." they probably did not set up multiple partitions. – Thomas Ward Jul 25 '13 at 16:01
I added the comment from the review panel so I didn't wholly read the OP's question. – papukaija Jul 25 '13 at 16:03
@papukaija OK. No problem. :) – Thomas Ward Jul 25 '13 at 16:04
OP here: The server was setup with multiple partitions, /var/www was on a separate partition. Definitely, though, I wouldn't have thought of this as a Linux noob. :-) – ericmjl Jul 27 '13 at 19:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.