Same MariaDB Database Instance and Web Scripts on Dual Boot Systems

The plan here is to allow you to have dual booting operating systems; where you will be able to “reuse” same copy of your database files and web scripts; regardless of what operating system you are in.

Audience: Mid to Expert web developer with experiences on Linux Shell Scripting and Apache, MySQL Administration.

Follow these simple steps:

  1. Prepare 3 partitions
    1. Operating System One (A)
    2. Operating System Two (B)
    3. Common/Dedicated disk space in NTFS format (C) – to host your Database Files and Web Scripts
  2. Install dual bootable operating systems, eg. Windows and Ubuntu, or any other combinations.
  3. Install XAMPP on both the systems. Focus installing exactly same version of the release; without modifying any default configurations.
  4. Windows: Move your data files and public_html to one of your free NTFS partition for safety reasons.
    1. Stop the server before you do anything
      1. net stop mysql
      2. net stop apache2.4
    2. Moving MySQL/MariaDB data files on Windows
      1. cd c:\xampp\mysql
      2. copy data d:\data
      3. mklink /d data d:\data
    3. Moving htdocs on Windows
      1. cd c:\xampp\
      2. ren htdocs htdocs.original
      3. mkdir d:\htdocs
      4. mklink /d htdocs d:\htdocs
    4. Restart the server and test; everything should be ok
      1. net start mysql
      2. net start apache2.4
  5. Linux: Move your data files
    1. Stop the server
      1. lampp stop
    2. Mount the NTFS data disk
      1. mount /dev/sda3 /media/WEB
    3. Moving mysql data files in Linux
      1. cd /opt/lampp/var
      2. move mysql mysql.original
      3. ln -s /media/WEB/data data
    4. Moving htdocs in Linux
      1. cd /opt/lampp
      2. move htdocs htdocs.original
      3. ln -s /media/WEB/htdocs htdocs
    5. Restart the server; everything should work
      1. lampp start

Now, you have your own choice to run which operating system you like. And, any change you make in your projects and database are instantly available to another operating system when you switch.

Reasons behind this success:

The MySQL or MariaDB database’s physical binary files are compatible and portable across multiple platforms. As long as you have exactly similar my.ini or my.cnf configurations (by value), they are compatible. The web scripts, eg. plain PHP files definitely do not require any special arrangements.

Whichever operating system you are working on, you will be accessing the same copy of your data files and web scripts.

Disclaimer: The actual implementation may differ on your environment. This article is a proven concept only.