MySQL 5.7 更改数据目录

编程入门 行业动态 更新时间:2024-10-22 20:23:35
本文介绍了MySQL 5.7 更改数据目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用 MySQL 5.7 和 CentOS 7.2.

I use MySQL 5.7 and CentOS 7.2.

一开始我在myf中的datadir配置是/var/lib/mysql

At first, my datadir configuration in myf is /var/lib/mysql

现在我想更改数据目录.

Now I want to change datadir.

我有两种方法:

首先,我将/var/lib/mysql 中的所有文件和目录复制到/home/data,然后运行chown -R mysql:mysql/home/data.但是当我运行 systemctl start mysqld 时,我收到错误消息:

First, I copy all files and directories in /var/lib/mysql to /home/data, and run chown -R mysql:mysql /home/data. But when I run systemctl start mysqld, I get error message:

2016-12-08T16:33:38.206780Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable 2016-12-08T16:33:38.206806Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable 2016-12-08T16:33:38.206817Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2016-12-08T16:33:38.807398Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2016-12-08T16:33:38.807421Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2016-12-08T16:33:38.807429Z 0 [ERROR] Failed to initialize plugins. 2016-12-08T16:33:38.807436Z 0 [ERROR] Aborting

其次,我将/var/lib/mysql 移动到/home 并在/var/lib 目录中运行 ln -s/home/mysql mysql.当我运行 systemctl start mysqld 时,我收到错误消息:

Second, I move /var/lib/mysql to /home and run ln -s /home/mysql mysql in /var/lib directory. When I run systemctl start mysqld, I get error message:

2016-12-08T16:48:28.958136Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation. 2016-12-08T16:48:28.958165Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory. 2016-12-08T16:48:28.958174Z 0 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions 2016-12-08T16:48:28.958184Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2016-12-08T16:48:29.558751Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2016-12-08T16:48:29.558792Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2016-12-08T16:48:29.558806Z 0 [ERROR] Failed to initialize plugins. 2016-12-08T16:48:29.558817Z 0 [ERROR] Aborting

我该如何处理?

推荐答案

这个问题是关于subdir权限的你应该编辑这个文件 /etc/apparmor.d/local/usr.sbin.mysqld/数据/r,/数据/** rwk,不要忘记,你应该在centos上找到相同的命令,就像这样

this problem is about subdir permission and you should edit this file /etc/apparmor.d/local/usr.sbin.mysqld /data/ r, /data/** rwk, do not forgot, and you should find same command at centos, like this

sudo service apparmor reload

关于 ubuntu sys 的这个问题,见链接

about this problem at ubuntu sys, and see link

askubuntu/questions/758898/mysql-wont-start-after-changed-the-datadir-14-04-mysql-5-7/795710#795710

快乐的一天,坏人

更多推荐

MySQL 5.7 更改数据目录

本文发布于:2023-10-16 00:25:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1495928.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:目录   数据   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!