首页 > 代码库 > mysql问题排查

mysql问题排查

系统删除了mysql用户,导致mysql重启报错,内容如下:

161025 21:24:55 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

/usr/libexec/mysqld: Can‘t find file: ‘./mysql/plugin.frm‘ (errno: 13)

161025 21:24:55 [ERROR] Can‘t open the mysql.plugin table. Please run mysql_upgrade to create it.

161025 21:24:55  InnoDB: Initializing buffer pool, size = 8.0M

161025 21:24:55  InnoDB: Completed initialization of buffer pool

161025 21:24:55  InnoDB: Operating system error number 13 in a file operation.

InnoDB: The error means mysqld does not have the access rights to

InnoDB: the directory.

InnoDB: File name ./ibdata1

InnoDB: File operation call: ‘open‘.

InnoDB: Cannot continue operation.

161025 21:24:55 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended


考虑到mysql服务使用mysql用户启动的,首先增加mysql用户,useradd -r mysql

修改目录权限:cd /var/lib/mysql

              chown -R mysql.mysql *

启动还是报错,显示信息:

161025 21:57:47 [ERROR] /usr/libexec/mysqld: Can‘t create/write to file ‘/var/run/mysqld/mysqld.pid‘ (Errcode: 13)

161025 21:57:47 [ERROR] Can‘t start server: can‘t create PID file: Permission denied

这个很明显了,mysql.pid没有权限生成

赋予权限:chown -R mysql.mysql /var/run/mysqld/

启动mysql,成功。

本文出自 “Linux技术交流” 博客,请务必保留此出处http://9678130.blog.51cto.com/9668130/1865708

mysql问题排查