Skip to content

MySQLfs is a FUSE - File System in User land - module which stores data in a MySQL database

License

Notifications You must be signed in to change notification settings

therobyouknow/mysqlfs

 
 

Repository files navigation

                      mysqlfs - MySQL FileSystem

MySQLfs is a FUSE filesystem driver which stores files in a MySQL database.

===> Requirements

  - mysql-client libraries 5.0 or later
  - mysql-server 5.0 or later
  - fuse 2.6 or later

===> Compatibility

  During development mysqlfs is checked against:

  * FreeBSD 9
  * Fedora Linux 15
  * Debian Linux 6

  And against MySQL 5.1 (mainly Linux) and MySQL 5.5 (mainly FreeBSD).

===> Build

  If compiling from version-control, use "autoreconf -vfi" first.

  For both version-control and tarball version run:
  $ ./configure
  $ make

===> Usage

  If you are UPGRADING from a previous version of mysqlfs please see below!

1. Create database and account
   mysql> CREATE DATABASE mysqlfs;
   mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON mysqlfs.* TO mysqlfs@"%" IDENTIFIED BY 'password';
   mysql> FLUSH PRIVILEGES;

   (note FAQ: Errors #1 "Access Denied For User" below)

2. Create tables
   $ mysql -uroot -p mysqlfs < sql/schema.sql

   (note FAQ: Errors #2 "Can't Create/Write to File" below)

3. Mount database as a filesystem
   $ mkdir fs
   $ ./mysqlfs -ohost=localhost -ouser=user -opassword=pass -odatabase=mysqlfs fs

4. Instead of setting connection options on the command line
   you may create a [mysqlfs] section in your ~/.my.cnf file and
   set the parameters there.

===> Upgrading from 0.4.1 or higher

   Upgrading from 0.4.1 or higher it's pretty simple. Close the running filesystem
   (yes, you have to), BACKUP YOUR DATABASE, and run

   $ ./update.sh

   Answer to all the question and watch your DB get updated. When the updated has
   finished, compile the new mysql, install it, and run it as usual.

===> Upgrading from 0.4.0 or lower

   To upgrade your existing installation unfortunately you have to make some changes
   to the database.

   The recomended solution to upgrade your system is to compile mysqlfs 0.4.1 and
   create a NEW filesystem in a NEW database. Mount it alongside the old one and then
   just copy datas from the old filesystem to the new one. THIS IS THE RECOMENDED
   (AND PROBABILY THE ONLY CERTAIN) SOLUTION.

   IN THE SQL DIR YOU CAN FIND A 0.4.0_to_0.4.1.sql FILE, BUT IT IS INFORMATIVE
   ONLY - IT'S NOT MEANT TO BE RUN ON A RUNNING FILESYSTEM

   The problem lies in the handling of "sparse files": increasing the blocksize
   without proper remapping of the underlying database can cause improper results.
   More specifically your files will probably get filled with zeroes. You probably
   don't want that.

===> Options

  -ohost=<hostname>
    MySQL server host

  -ouser=<username>
    MySQL username

  -opassword=<password>
    MySQL password

  -odatabase=<db>
    MySQL database name

  -obig_writes
    Enable big_writes (strongly suggested) - works only under Linux

  -oallow_other
    Enable filesystem access to different users than the one who mounted it.
    The corresponding option must be enabled in /etc/fuse.conf

  -odefault_permissions
    Disable some extended permission checkings on files. Seems mandatory on
    FreeBSD!

===> FAQ: ERRORS

1. Access Denied For User 'mysql'@'localhost'

   ie: (using the example GRANT above) 
   $ ./mysqlfs -ohost=localhost -ouser=mysqlfs -opassword=password -odatabase=mysqlfs fs

   2009-06-14 00:59:29 89956 ERROR: mysql_real_connect(): Access denied for user 'mysqlfs'@'localhost' (using password: YES)
   2009-06-14 00:59:29 89956 ERROR: mysql_real_connect(): Access denied for user 'mysqlfs'@'localhost' (using password: YES)
   2009-06-14 00:59:29 89956 Failed to connect MySQL server.
   2009-06-14 00:59:29 89956 Error: pool_init() failed

   MySQL is sticky sometimes with access; on MacOSX, I had to specifically allow localhost:

   mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON mysqlfs.* TO mysqlfs@"localhost" IDENTIFIED BY 'password';

   $ sudo /usr/local/mysql/bin/mysqladmin reload

   Remember, also, that 'localhost' and '127.0.0.1' may appear differently.  Check also your /etc/hosts entry, some
   systems define 127.0.0.1 as their uname() which causes problems doing PTRs against it, expecting 'localhost'
   but getting 'myhostname'


2. Can't Create/Write to File (while building database)

   ie: (using the "Create tables" step #2 above)
   $ sudo /usr/local/mysql/bin/mysql mysqlfs < schema.sql
   ERROR 1 (HY000) at line 23: Can't create/write to file '/usr/local/mysql/data/mysqlfs/data_blocks.MYI' (Errcode: 13)

   On MacOSX with http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.35-osx10.5-x86.dmg ,
   rather than "CREATE DATABASE mysqlfs", I had to use:

   $ sudo /usr/local/mysql/bin/mysqladmin create mysqlfs && sudo chown _mysql /usr/local/mysql/data/mysqlfs

   The grant/flush commands worked fine after that.  In my usage, I'm "sudo" which can affect the output, so the
   error might have been mine alone.  I'm commenting here in case someone else sees it.

===> Authors

Copyright (C) 2006 Tsukasa Hamano <code@cuspy.org>
Copyright (C) 2006 Michal Ludvig <michal@logix.cz>
Copyright (C) 2012 Andrea Brancatelli <andrea@brancatelli.it>

About

MySQLfs is a FUSE - File System in User land - module which stores data in a MySQL database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published