在mysql中创建一个只读表

时间:2022-09-11 16:51:53

How can I make a single table in mysql read only for a user while he still has write access to other tables in the same db?

我如何在mysql中为一个用户创建一个单独的表,而他仍然可以访问相同数据库中的其他表?

Additional info

额外的信息

  • I have root access to the server
  • 我有对服务器的根访问权限
  • Tables are MyISAM
  • MyISAM表
  • Server version is 5.0.51a-24+lenny2
  • 服务器版本是5.0.51a-24 + lenny2

thanks!

谢谢!

2 个解决方案

#1


8  

Revoke all previous privileges and then grant the specific new privileges:

撤销所有先前的特权,然后授予特定的新特权:

REVOKE ALL ON db.table FROM user;
REVOKE ALL ON db.othertable FROM user;
GRANT SELECT ON db.table TO user;
GRANT SELECT, INSERT, UPDATE, DELETE ON db.othertable TO user;

#2


3  

You can make a single MyISAM table read only by compressing the table. Use myisampack on the command line to pack the table.

只能通过压缩该表来读取一个MyISAM表。在命令行上使用myisampack来打包表。

More info can be found in the MySQL Manual: http://dev.mysql.com/doc/refman/5.0/en/myisampack.html

更多信息可以在MySQL手册中找到:http://dev.mysql.com/doc/refman/5.0/en/myisampack.html

#1


8  

Revoke all previous privileges and then grant the specific new privileges:

撤销所有先前的特权,然后授予特定的新特权:

REVOKE ALL ON db.table FROM user;
REVOKE ALL ON db.othertable FROM user;
GRANT SELECT ON db.table TO user;
GRANT SELECT, INSERT, UPDATE, DELETE ON db.othertable TO user;

#2


3  

You can make a single MyISAM table read only by compressing the table. Use myisampack on the command line to pack the table.

只能通过压缩该表来读取一个MyISAM表。在命令行上使用myisampack来打包表。

More info can be found in the MySQL Manual: http://dev.mysql.com/doc/refman/5.0/en/myisampack.html

更多信息可以在MySQL手册中找到:http://dev.mysql.com/doc/refman/5.0/en/myisampack.html