Mysql – Moving MySQL database from UniServer to Ubuntu Server

MySQLUbuntu

I have set up Ubuntu Server 11.10, and plan to host my website on it. Until this point I was using UniServer to host it in a portable fashion. Using the built in MySQL. This is fine, and through testing, I have gathered a decent amount of info in my database that I really don't want to have to re-enter.

The problem is; that I cant find any help online to install the existing databases into MySQL on the Ubuntu side of things. I can Export the existing databases from UniServer, no problem. But once I've copied them over to Ubuntu, how do I get MySQL to read them.

For anyone that doesn't know, Ubuntu Server is a Command Line Interface OS. While I do have a Debian Graphical User Interface installed (accidentally), it doesn't allow much to be done graphically, other then file system search, copy, cut, paste, etc. Terminal application, and a minimalist web browser.

Any help that can anyone can give here is greatly appreciated. I am a Linux newbie, so simplified jargon is also appreciated, but I am very eager to learn!

Best Answer

The simplest option is to just back up everything in the filesystem and carry it over.

To find out where your data is, look at the datadir variable with in mysql

test> show variables like 'datadir';
+---------------+-------------------+
| Variable_name | Value             |
+---------------+-------------------+
| datadir       | /var/lib/mysql/   |
+---------------+-------------------+
1 row in set (0.00 sec)

Note Your actual value may differ.

Then from your shell shut down mysql, back it up and copy it over. Something like:

> sudo service mysql shutdown
> cd /var/lib/mysql
> sudo tar -czf /path/with/enough/space/db.tgz *

Copy your db.tgz over to your new server and uncompress it on your new servers datadir while it is shutdown