views:

98

answers:

2

hi,

i wanna use databases in D:\xampp\mysql\data in my linux mysql without moving it. so i can work on them from both linux and windows

here is what i did:

# mount -t ntfs -o uid=mysql,gid=mysql,dmask=002,fmask=113 /dev/sda5 /media/public/
# cd /var/lib/mysql
# ln /media/public/xampp/mysql/data/my_db -s
# chown -R mysql:mysql /var/lib/mysql/my_db

but mysql cannot read the database tables

use my_db
show tables

gives error: mysql cannot read the directory './my_db'

it seems this is a permission issue. what should i do?

PS: there is only one machine with two operating systems, Windows and Linux. and i want to use the same directory as datadir when i am in Windows or Linux.

PS: i tried ntfs-3g. now mound partition and all it's content ownership is mysql:mysql. the /var/lib/mysql/my_db is mysql:mysql too. but i still got the following error on show tables

ERROR 1018 (HY000): Can't read dir of './my_db/' (errorno: 13)

+2  A: 

First off, never allow more than one instance of MySQL to use the data files at the same time. It's a recipe for disaster.

Second, why do you need MySQL's server on both machines? Why not just use the client on the linux machine to connect via the network to the server on the windows machine?

Third, if you really must do this, I'd suggest enabling master-master replication between them. So each server would have its own storage, and would communicate the changes back and forth automatically.

Edit

Ahhh, wait... Are you dual booting? If so, you need to make sure the entire /var/lib/mysql directory is readable by the mysql user. It's not enough for you to just chmod the my_db folder.

Oh, and how did you link the mount point to the data directory for MySQL (That's not in your list of commands)...

ircmaxell
thanks for you informational answer. i used it. but this is not my case. there is only one machine with two O.S.s. i want to use a single directory as datadir both when i logged in Windows and Linux.
takpar
I edited that in. So long as one server is active at a time, you should be ok (Dual-Boot scenario)...
ircmaxell
ye, dual booting. and i use `ln -s` to create a soft link of the database directory in /var/lib/mysql
takpar
Ahhh ok. Try `chown -R mysql:mysql /var/lib/mysql`. Also check out your `my.cnf` to make sure it's looking in the right place for the data directory...
ircmaxell
ye, `my.cnf` is on it's default `/var/lib/mysql`.
takpar
Did you sym-link the entire directory? What about trying to change the default from `/var/lib/mysql` to `/media/public/xampp/mysql/data`?
ircmaxell
A: 
ls /media/public/xampp/mysql/data/my_db

OK, have you pointed the datadir config in my.cnf to /media/public/xampp/mysql/data so MySQL knows where to look for it?

Re: edit:

ln /media/public/xampp/mysql/data/my_db -s

Oh... do you mean ln -s /media/public/xampp/mysql/data/my_db /var/lib/mysql/my_db?

mount -t ntfs

ntfs gives you the kernel NTFS filesystem support, which is read-only. If you want to be able to write to the files, you'll need ntfs-3g, assuming it is installed (most modern distros do).

bobince
shoud i `mount -t ntfs-3g ...`?
takpar
i used ntfs-3g. now /media/public is mysql:mysql. but still error
takpar
hmm, does still sound permissionsey. What distro are you running, are SELinux or AppArmor in play?
bobince
i use Ubuntu 10.04.
takpar