Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I recently installed a portable WAMP server on my usb stick. Really nice, I can do some php programming on my girlfriend's windows7 laptop without installing anything on it.

I also have a LAMP environnement on my linux computer.

When I plug my usb stick on my linux box, I can easily mount -o bind /usbstick/wwwfolder ~/public_html and work on my php script from there.

But my question is, is there a way I could get the database from my usb stick's MySql server, to run on my linux MySql server? So I can modify data base schema from my Linux workstation, doing some INSERTS in some tables, and then plub my usb stick on the laptop and get my up-to-date database running from the portable environnement?

I don't know where / how MySql stores its databases.

EDIT: Basically, I want to "mount" the database from the usb stick in my Linux' installed MySql server, without extracting and importing the data, so there is just ONE database used for BOTH environnement. Hope this helps clarify the question.

share|improve this question
1  
I completely understand the appeal of a 100% portable environment, but it seems like there's more to lose than there is to gain by keeping your datastore on a flash stick. Those things tend to get lost, get washing-machined, and sometimes just go bad for no good damn reason. –  redperl Jul 30 '11 at 21:02
    
Well I'm not using this for professional use, just for some test that I don't really care if I loose. –  Johnny5 Jul 31 '11 at 17:12
add comment

migrated from stackoverflow.com Aug 1 '11 at 4:54

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 4 down vote accepted

When you start the MySQL Server, you can specify --datadir, so you could probably script something to get MySQL to use the data on the USB stick.

share|improve this answer
    
Looks like what I wanted, I'll just try to find where are the database on the usb key and I'll test it... –  Johnny5 Jul 31 '11 at 17:18
    
I think I got some permission problems... –  Johnny5 Jul 31 '11 at 18:02
    
Although that seems to be the solution I got some errors so that does not run yet. Another solution is to mount the database folder of my usb key, like : mount -o bind /media/myUsbStick/pathToProtableMySql/data/MyDataBase /var/lib/mysql/MyDataBase –  Johnny5 Aug 1 '11 at 2:50
    
Please be careful with this one because files on USB may not have a proper FAT when accessing it. This can be true using Windows Media files. –  RolandoMySQLDBA Aug 1 '11 at 21:13
add comment

If you're doing some kind of light development in this way, I'd recommend you use sqlite rather than mysql. YOu can simply copy the file around and not worry about the database. IF you have a database abstraction layer, this can be done quite easily.

share|improve this answer
    
I've never tried sqlLite, and since mySql was in the portable wamp package I did not think of another option, but that seems interesting. –  Johnny5 Jul 31 '11 at 18:07
add comment

Using a USB Flash Stick for a MySQL database is a really bad idea. You are guaranteed to lose that data. A USB Flash stick only has so many reads/writes. Read up on Flash Drive Wear Leveling.

share|improve this answer
    
I know all that, but I'm not using this for professionnal use, just some test case, I don't care if I loose these data. As for reads/writes limits, you are completely right, but I have never reached it. –  Johnny5 Jul 31 '11 at 17:15
add comment

Your Answer

 
discard

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.