LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 857|回复: 2

有什么办法可以限制mysql数据库的大小?

[复制链接]
发表于 2005-5-7 20:03:03 | 显示全部楼层 |阅读模式
怎么可以限制不同用户数据库的大小呢?

linux的磁盘配额只能针对用户设置,mysql的用户都是同一个,我想了好久都想不出什么办法,各位大哥有什么方法吗?
发表于 2005-5-8 13:26:32 | 显示全部楼层
How can I limit the size of MySQL databases?

Jan 28th, 2000 11:56

Benjamin Pflugmann, Nathan Wallace
Benjamin Pflugmann




MySQL has no built in method for doing db size limits, but since mysql
runs on your OS's file system, you might be able to specify disk limits
there.

You don't need to worry about this leaving your database in an
inconsistent state.  AFAIK, MySQL should behave as in a "disk full"
condition, which will not leave an inconsitent state. The exact
behaviour is documented in the manual.

But you won't get an error, but MySQL will get "hanging" threads, even
up to the state where no new connections are accepted. This will
'heal' as soon as you make free space available.

If your OS supports group quotas, you can even set different limits for
each database user - as long as there is a corresponding system user
with an own group (like ftp1003):

So, change the group of the database directory in question to group
"ftp1003" (or whatever it is) and let the user id as it is (probably
root or mysql). Additionally set the set-group-id flag of the directory
(chmod +s), which will assure that new table files will inherit the
group.

Then set the group quota (you have to find out yourself how, I only
know, that it is possible), and you are done.

The quota will include all files of this group, so you might give the
user an additional group if you want to give him a different mysql
quota than quota for uploaded files.
   
The commands from above could look like (for database "test" on a Linux
system)
        
cd <where-your-mysql-database-is>
chgrp ftp1003 test
chmod g+s test
回复 支持 反对

使用道具 举报

发表于 2005-5-14 15:09:03 | 显示全部楼层
把库文件放到用户目录里,然后ln -s 到 var目录
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表