Linux:MySQL:如何使用安装在 NTFS 上的 mysql 数据库作为 Linux 中的 mysql 数据库?

发布于 2024-09-15 07:32:18 字数 838 浏览 2 评论 0原文

我想在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

花之痕靓丽 2024-09-22 07:32:18

首先,绝不允许多个 MySQL 实例同时使用数据文件。这是灾难的根源。

其次,为什么两台机器上都需要MySQL的服务器?为什么不直接使用linux机器上的客户端通过网络连接到windows机器上的服务器呢?

第三,如果您确实必须这样做,我建议启用主-主复制< /a> 他们之间。因此,每个服务器都有自己的存储,并且会自动来回传送更改。

编辑

啊哈,等等...你是双启动吗?如果是这样,您需要确保 mysql 用户可以读取整个 /var/lib/mysql 目录。仅 chmod my_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 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)...

单身狗的梦 2024-09-22 07:32:18
ls /media/public/xampp/mysql/data/my_db

好的,您是否已将 my.cnf 中的 datadir 配置指向 /media/public/xampp/mysql/data,以便 MySQL 知道在哪里查找它?

回复:编辑:

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

哦...你的意思是 ln -s /media/public/xampp/mysql/data/my_db /var/lib/mysql/my_db 吗?

mount -t ntfs

ntfs 为您提供内核 NTFS 文件系统支持,该文件系统是只读的。如果您希望能够写入文件,则需要 ntfs-3g(假设已安装)(大多数现代发行版都已安装)。

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).

辞旧 2024-09-22 07:32:18

您可能需要按照以下博客文章将新数据目录添加到 /etc/apparmor.d/usr.sbin.mysqld 中的目录列表中: http://www.lucasward.net/2011/05/moving-mysql-data-directory-beware-of.html< /a>

像这样:

/new-mysql-datadir/ r,
/new-mysql-datadir/** rwk,

您可以通过查看 /var/log/messages 并查看是否有与此类似的错误消息来确认这是您的问题:

Aug  6 14:47:23 tinybeast kernel: [20254.145552] type=1400 audit(1344228443.102:54): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=24202 comm="apparmor_parser"
Aug  6 14:47:23 tinybeast kernel: [20254.165438] type=1400 audit(1344228443.122:55): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/mysqld" name="/media/data/mysqldata/tinybeast.lower-test" pid=24206 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
Aug  6 14:47:23 tinybeast kernel: [20254.165718] type=1400 audit(1344228443.122:56): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/mysqld" name="/media/data/mysqldata/tinybeast.lower-test" pid=24206 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
Aug  6 14:47:23 tinybeast kernel: [20254.167606] type=1400 audit(1344228443.126:57): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/mysqld" name="/media/data/mysqldata/mysql/plugin.frm" pid=24206 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Aug  6 14:47:23 tinybeast kernel: [20254.186759] type=1400 audit(1344228443.146:58): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/mysqld" name="/media/data/mysqldata/ibdata1" pid=24206 comm="mysqld" requested_mask="rw" denied_mask="rw" fsuid=0 ouid=0

为了确认我的消息来源,我从上述博客文章中了解到了所有这些,我'我只是在这里发布特定部分,以防该帖子的链接变得过时。

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:

/new-mysql-datadir/ r,
/new-mysql-datadir/** rwk,

You can confirm that this is your problem by looking in /var/log/messages and seeing if you have error messages similar to this:

Aug  6 14:47:23 tinybeast kernel: [20254.145552] type=1400 audit(1344228443.102:54): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=24202 comm="apparmor_parser"
Aug  6 14:47:23 tinybeast kernel: [20254.165438] type=1400 audit(1344228443.122:55): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/mysqld" name="/media/data/mysqldata/tinybeast.lower-test" pid=24206 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
Aug  6 14:47:23 tinybeast kernel: [20254.165718] type=1400 audit(1344228443.122:56): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/mysqld" name="/media/data/mysqldata/tinybeast.lower-test" pid=24206 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=0 ouid=0
Aug  6 14:47:23 tinybeast kernel: [20254.167606] type=1400 audit(1344228443.126:57): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/mysqld" name="/media/data/mysqldata/mysql/plugin.frm" pid=24206 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Aug  6 14:47:23 tinybeast kernel: [20254.186759] type=1400 audit(1344228443.146:58): apparmor="DENIED" operation="open" parent=1 profile="/usr/sbin/mysqld" name="/media/data/mysqldata/ibdata1" pid=24206 comm="mysqld" requested_mask="rw" denied_mask="rw" fsuid=0 ouid=0

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文