简体   繁体   English

Mysql给我:“无法打开和锁定特权表:表'主机'是只读的”

[英]Mysql gives me:“Can't open and lock privilege tables: Table 'host' is read only”

I am facing problem restoring the mysql database. 我在还原mysql数据库时遇到问题。 My primary database was mysql5.1 and now I am trying to copy it to mysql5.5. 我的主数据库是mysql5.1,现在我正尝试将其复制到mysql5.5。 The database was backed by using Xtrabackup . 通过使用Xtrabackup支持数据库。

I am using Ubuntu 12.04.3 LTS on this server, mysql version is : 5.5.32-0ubuntu0.12.04.1-log 我在此服务器上使用Ubuntu 12.04.3 LTS,MySQL版本为:5.5.32-0ubuntu0.12.04.1-log

I have followed all the steps to restore using Xtrabackup , this created database files, which I have copied to a tmp directory. 我已经按照所有步骤使用Xtrabackup还原了,这个创建的数据库文件已经复制到tmp目录中。

I have modified my.cnf to point to this tmp directory. 我修改了my.cnf使其指向该tmp目录。 I have changed the tmp directory permissions and changed the ownership of the files to mysql user. 我已经更改了tmp目录权限,并将文件的所有权更改为mysql用户。 drwxr-xr-x 12 mysql mysql 4096 Sep 10 10:04 base drwxr-xr-x 12个mysql mysql 4096 Sep 10 10:04 base

Now when I start the mysql server I get this error "[ERROR] Fatal error: Can't open and lock privilege tables: Table 'host' is read only" 现在,当我启动mysql服务器时,出现此错误“ [ERROR]致命错误:无法打开和锁定特权表:表'host'是只读的”

I have given a try as follows: 我尝试如下:

  1. Even tried installing mysql5.1 to see if that was the issue. 甚至尝试安装mysql5.1来查看是否是问题所在。
  2. tried 'chcon mysql_db_t' to change the context but it gives me "can't apply partial context to unlabelled file" 试图'chcon mysql_db_t'更改上下文,但是它给我“不能将部分上下文应用于未标记的文件”
  3. I have used --skip-grant to get into database, but using this I can only access innodb tables only, MyIsam tables throw read-only error 我已经使用--skip-grant进入数据库,但是使用此方法我只能访问innodb表,MyIsam表抛出只读错误
  4. After --skip-grant, I have used upgrade_mysql this throws me error that many tables are read-only. 在--skip-grant之后,我使用了upgrade_mysql,这引发了很多表为只读的错误。
  5. I have removed apparmor too. 我也删除了apparmor。 and restarted too. 并重新启动。
  6. I have restored a different database(5.1 to 5.5) previously on Ubuntu 12.04.2 LTS without any issues. 我以前在Ubuntu 12.04.2 LTS上还原了另一个数据库(5.1至5.5),没有任何问题。

Can some please point me in right direction, I am not sure whats wrong with permissions. 能否请您指出正确的方向,我不确定权限有什么问题。

Thanks in advance. 提前致谢。

Answering my own question, 回答我自己的问题,

The issue is with AppArmor. 问题出在AppArmor。 I am not sure why MySql is unable to access files even after uninstalling AppArmor. 我不确定为什么即使卸载AppArmor后MySql也无法访问文件。

Reinstalled AppArmor and moved the MySql profile under disabled profiles of AppArmor, even then it did not work. 重新安装了AppArmor,并将MySql配置文件移到了禁用的AppArmor配置文件下,即使那样也不起作用。

I copied the database files under /var/lib/mysql/ and MySql stopped throwing errors 我将数据库文件复制到/ var / lib / mysql /下,MySql停止抛出错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命错误:无法打开和锁定权限表:表 'mysql.host' 不存在 - Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist Docker中的Bootstraping Percona Xtradb Cluster出现错误:无法打开和锁定特权表:表'mysql.user'不存在 - Bootstraping Percona Xtradb Cluster in Docker gives the error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist Mysql/mariadb“无法打开和锁定权限表:表‘mysql.servers’不存在” - Mysql/mariadb "Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist" 移动数据后无法运行mysql(严重错误:无法打开和锁定特权表:表'mysql.host'不存在) - Cannot run mysql after moving data (Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist) 无法打开和锁定权限表:表 'mysql.user' 不存在 - Can't open and lock privilege tables: Table 'mysql.user' doesn't exist MySQL致命错误:无法打开和锁定权限表:文件格式“用户”不正确 - MySQL Fatal error: Can't open and lock privilege tables: Incorrect file format 'user' 如何修复致命错误:无法打开和锁定特权表:表 '.\mysql\proxies_priv' 被标记为已崩溃并且最后(自动?)修复失败 - How do I fix Fatal error: Can't open and lock privilege tables: Table '.\mysql\proxies_priv' is marked as crashed and last (automatic?) repair failed 是否存在只能用于读取 MySQL 中的数据库结构的权限类型? - is there a privilege type which can be used only to read database structure in MySQL? 锁定表以读取 MYSQL - LOCK a table for READ MYSQL 我的SQL错误#1015 - 无法锁定文件(错误:165 - 表格只读)只有innodb引擎 - My SQL error #1015 - Can't lock file (errno: 165 - Table is read only) innodb engine only
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM