12

I have dual boot mode with Windows 7 and Ubuntu 10.

On Windows 7 I have XAMPP installed, on Linux I have LAMP installed.
Is it possible to force the MySQL DB servers installed onto different operating systems (even though they would be of identical versions, they are different) to use the same physical files?

So in dual boot mode, independently from the fact that I ran another operating system, I would be able to use the same physical data. Sometimes I'd like to switch OS but it would be great to be able to use the same databases.

Sk8erPeter
  • 6,899
  • 9
  • 48
  • 67
Jan
  • 121
  • 1
  • 3
  • 1
    Interesting question. In theory, this *should* work - the underlying file format is supposed to be identical. I'm somehow not entirely comfortable with the idea, though. Interested to see what comes up – Pekka Jan 09 '11 at 11:58
  • "without any programs which can slow down my work - google talk, ICQ for example" --- why don't you just not run it? ;-) – zerkms Jan 09 '11 at 12:02
  • Hi. Have you found the answer? Does it work? I need the same. If you've found the answer - please accept (if it's among the answers already given) it or post your own. – Ivan Oct 14 '11 at 00:51
  • found this: http://www.irisoftonline.com/dual-booting-linux-and-windows-while-sharing-xampp-web-applications-code-and-database going to try it myself. involves symlinks... so seems logical. – helgatheviking Feb 29 '12 at 19:20
  • 1
    See my extensive similar solution here: http://unix.stackexchange.com/questions/170751/sharing-mysql-data-between-windows-and-linux/310712#310712 in Unix & Linux StackExchange. – Elliptical view Sep 18 '16 at 21:23
  • @Ivan: I'm sorry, but back then I couldn't solve it, but since then I haven't tried it yet, but I definitely will as soon as I have time to set up dual boot mode again (maybe on a VM). Were you able to make it work? – Sk8erPeter Apr 21 '20 at 06:11
  • @Ellipticalview: Thanks! Your answer seems very promising, I'll definitely check that out! – Sk8erPeter Apr 21 '20 at 06:13

5 Answers5

5

in your my.ini (in Windows it's located somewhere like C:\Program Files\MySQL\MySQL Server 5.1. It's the main configuration file for MySQL) file, you should have this line:

datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/" for example

change it in both Windows and Linux Ubuntu to point to one single physical folder (on a partition with a file system which Windows could recognize). It will work. File formats are identical.

Whether you boot from Ubuntu, or Windows 7, it won't matter, 2 different builds of MySQL will be looking for data in the same place. Once data is modified in Windows environment, you boot up from Ubuntu and the data is there, modified.

Alex
  • 14,338
  • 5
  • 41
  • 59
  • If you happen to use InnoDB tables in your DB, more fun goes on. In my case, I need to delete the ib_logfile0 and ib_logfile1 files from the MySQL data directory every time before the MySQL server is started up. The logfiles get recreated on server startup. You can automate it using scripts. Be careful when trying this - make backups of all the changed/deleted files! – Martin Pecka Jun 14 '13 at 08:44
  • I don't know if it's due to InnoDB or something else, but I was forced to pretend the "mysql" user owns the database files. That can be simply done in fstab: bindfs#/media/Windows/PHP/mysql-data /media/mysql fuse owner=mysql,group=mysql,perms=755 0 0 – Martin Pecka Jun 14 '13 at 08:45
4

Whilst not ideal, this should be fine as long as:

  1. You're using identical versions of MySQL on both operating systems.

  2. You shutdown mysqld before you copy the data files across. (If you're going to be copying the data files between partitions rather than keeping them on a shared fat32 partition).

In essence, as long as MySQL is running on an architecture of the same "endianness", then the file formats should be transferable.

As a suggestion, you could just close ICQ, etc. and use the free memory to run Ubuntu within a VirtualBox virtual machine on top of Windows 7 - hence ensuring you can trivially access your development environment without having to restart, etc.

This is actually quite a nice set up as it means you can use a Windows development environment if you want and simply host the site web site data on a Samba mount on the Ubuntu virtual machine.

John Parker
  • 54,048
  • 11
  • 129
  • 129
  • I second this and AlexanderMP's answer. However, having to switch OSs just to focus sounds like you need more fundamental help. :) – Noufal Ibrahim Jan 09 '11 at 13:13
1

As long as the data is sharedable/reable/writeable on both OS, and both file format are identical on both OS, it should be doable

The first problem I can imagine is the case insensitivity in windows.
so, convert your database/table ti camel_case (or camelcase) if you are always using CamelCase.

More information to read up - http://dev.mysql.com/doc/refman/5.0/en/limits-windows.html

ajreal
  • 46,720
  • 11
  • 89
  • 119
-1

Of course you can.
But I dont think, it is possible for your dual boot system.

Lets assume, your MySQL server is installed under Win7 machine. You can perfectly access it from Win7 enviroment, and even from Linux enviroment (if you do not deny access in your MySQL server settings). The system, which is your MySQL installed under, has to be running! Then you can access it from multiple systems if allowed ;-)

Andreyco
  • 22,476
  • 5
  • 61
  • 65
  • 1
    how would you run two system on one machine ?!!?!? –  Apr 14 '11 at 10:51
  • The original purpose was to be able to force the DB servers installed onto different operating systems (even though they would be of identical versions, they are different) to use the same physical files. So in dual boot mode, independently from the fact that I ran another operating system, I would be able to use the same physical data. (Of course only one OS may run at the same time.) – Sk8erPeter Apr 21 '20 at 05:38
-3

I goggled a lot of time and found that running a Linux kernel is a solvable way and feasible solution.

Vagrant

It is a tool for building and managing virtual machine environments in a single workflow. The main reason why I argue you using vagrant is that it is not too heavy and does not swallow much of your computer resources. I believe you get through Vagrant documentation that will allow you to launch a Linux based machine on your physical machine.

Let's assume that the host machine is assigned IP 192.168.1.2 and the virtual machine has the IP address as 192.168.1.10, and make sure that the host and guest machine could see each other. Please read thoroughly Networking section to customise the network configuration.

Verifying connection between host and guest machine

Install MySQL Server

MySQL is a database management system. Basically, it will organise and provide access to databases where our site can store information.

Open a terminal in the machine has been set up from the above step. Run the following command:

sudo apt-get install mysql-server-5.6

Notes: It's up to the version of Linux distribution installed, the above command would be adjustable to suit your need. For install, I used the core of Ubuntu 14.04, see the link.

During the installation, your server will ask you to select and confirm a password for the MySQL root user. This is an administrative account in MySQL that has increased privileges.

Verifying the installation From a terminal in the guest machine (i.e. the virtual machine), run the following command:

mysql -u root -p

will ask the MySQL password, then provide the one you have set up during MySQL Server installation. The following is the screenshot if you feed correct information to MySQL server.

enter image description here

Turn MySQL Server remotely accessible

Because we need a centralised database server where other computers could access and connect to the database of interest. Again, open a terminal and run the following MySQL commands:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.2' IDENTIFIED BY PASSWORD '*4ACFE3202A5FF5CF467898FC58AAB1D615029441' WITH GRANT OPTION; GRANT PROXY ON ''@'' TO 'root'@'192.168.1.2' WITH GRANT OPTION; FLUSH PRIVILEGES;

which 192.168.1.2 is the IP address of the host machine and hashed string of password gets from user table in mysql database.

Okay. You might take a rest and enjoy your drink if there is no issue so far.

Verifying the remote access

From a terminal on the host machine, fire up the following command:

mysql -h192.168.1.2 -uroot -p

which is asking you to enter the password. If the root credential is correct, you would see a screenshot like the above one. One thing needs to be paid attention is to add -h192.168.1.2 following mysql command because we are not in the machine where MySQL server is installed.

All in all, we have set up a MySQL server used for both host and guest machine. In reality, if I have another machine assigned 192.168.1.3 can also connect to the database server and exchange data between server and client.

Tung
  • 1,579
  • 4
  • 15
  • 32
  • 1
    Do you really think this is an ANSWER to the question?! – Sk8erPeter Aug 27 '13 at 12:05
  • @Sk8erPeter: This is an my suggestion because we can run a virtual box playing as a web server. I think this solution can work well. And I had tried this. – Tung Oct 14 '13 at 07:16
  • First of all, you didn't answer anything. You just wrote you Googled it, and found that it's doable. Congratulations for that! :D But how does this help ANYONE? You didn't go into details HOW to do it, and Stack Overflow is a forum for HELPING each other, not just awaiting upvotes for some bullsh÷t which contains nothing relevant and nothing helpful. I suggest you delete your answer not to get more downvotes for that (which unfortunately you deserve, sorry) OR editing it to share something useful (but in this case you'd better delete this one and write a new answer). – Sk8erPeter Oct 14 '13 at 09:51
  • 1
    @Sk8erPeter, even when you are right, I don't think that the rudeness is necessary. – Jaime Hablutzel Apr 19 '20 at 22:31
  • After a coupe of years, I had updated my answer based on my experience and from what I gained. Thanks @JaimeHablutzel for your nice word. No one feels my updated solution worthy to be up-voted. – Tung Apr 20 '20 at 06:50
  • @JaimeHablutzel: I guess you're right. :) This was many years ago. :) Although I still don't understand why Tung doesn't delete his answer which does not solve the original issue at all. I would definitely upvote his post if there was anything helpful in it which is related to the original question. – Sk8erPeter Apr 21 '20 at 05:28
  • @Sk8erPeter: Could you please read through my updated answer above? Are you able to find any helpful point? I showed how to set up an environment where we can share a database server, e.g. vagrant, rather than firing up a VM. That's doable. Especially, it can replace with a container in the age of dockerisation. – Tung Apr 21 '20 at 08:45