Linux:MySQL:如何使用安装在 NTFS 上的 mysql 数据库作为 Linux 中的 mysql 数据库?
我想在我的 linux mysql 中使用 D:\xampp\mysql\data 中的数据库而不移动它。所以我可以从linux和windows上处理它们,
这就是我所做的:
# 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
但是mysql无法读取数据库表
use my_db
show tables
给出错误:mysql无法读取目录'./my_db'
这似乎是一个权限问题。我应该怎么办?
PS:只有一台机器,有两个操作系统,Windows和Linux。 当我在 Windows 或 Linux 中时,我想使用与 datadir
相同的目录。
PS:我尝试了ntfs-3g
。现在mound分区及其所有内容所有权都是mysql:mysql
。 /var/lib/mysql/my_db 也是 mysql:mysql
。但我在 show table
上仍然出现以下错误
ERROR 1018 (HY000): Can't read dir of './my_db/' (errorno: 13)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,绝不允许多个 MySQL 实例同时使用数据文件。这是灾难的根源。
其次,为什么两台机器上都需要MySQL的服务器?为什么不直接使用linux机器上的客户端通过网络连接到windows机器上的服务器呢?
第三,如果您确实必须这样做,我建议启用主-主复制< /a> 他们之间。因此,每个服务器都有自己的存储,并且会自动来回传送更改。
编辑
啊哈,等等...你是双启动吗?如果是这样,您需要确保
mysql
用户可以读取整个/var/lib/mysql
目录。仅 chmodmy_db
文件夹是不够的。哦,你是如何将安装点链接到 MySQL 的数据目录的(这不在你的命令列表中)...
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 themysql
user. It's not enough for you to just chmod themy_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)...
好的,您是否已将 my.cnf 中的
datadir
配置指向/media/public/xampp/mysql/data
,以便 MySQL 知道在哪里查找它?回复:编辑:
哦...你的意思是
ln -s /media/public/xampp/mysql/data/my_db /var/lib/mysql/my_db
吗?ntfs
为您提供内核 NTFS 文件系统支持,该文件系统是只读的。如果您希望能够写入文件,则需要ntfs-3g
(假设已安装)(大多数现代发行版都已安装)。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:
Oh... do you mean
ln -s /media/public/xampp/mysql/data/my_db /var/lib/mysql/my_db
?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 needntfs-3g
, assuming it is installed (most modern distros do).您可能需要按照以下博客文章将新数据目录添加到 /etc/apparmor.d/usr.sbin.mysqld 中的目录列表中: http://www.lucasward.net/2011/05/moving-mysql-data-directory-beware-of.html< /a>
像这样:
您可以通过查看 /var/log/messages 并查看是否有与此类似的错误消息来确认这是您的问题:
为了确认我的消息来源,我从上述博客文章中了解到了所有这些,我'我只是在这里发布特定部分,以防该帖子的链接变得过时。
You may need to add the new data directory to the list of directories in /etc/apparmor.d/usr.sbin.mysqld as per this blog post: http://www.lucasward.net/2011/05/moving-mysql-data-directory-beware-of.html
like so:
You can confirm that this is your problem by looking in /var/log/messages and seeing if you have error messages similar to this:
To acknowledge my sources I learned all this from the aforementioned blog post, I'm just posting the particular parts here in case the link to the post ever goes stale.