Home > Database > Mysql Tutorial > body text

Ubuntu 10.04下修改MySQL的datadir的问题

WBOY
Release: 2016-06-07 16:58:05
Original
916 people have browsed it

由于服务器空间告紧,需要将Ubuntu 10.04下mysql的datadir从默认的/var/lib/mysql移到/usr/local/mysql下,操作如下:1.修改了/e

由于服务器空间告紧,需要将Ubuntu 10.04下mysql的datadir从默认的/var/lib/mysql移到/usr/local/mysql下,操作如下:

1.修改了/etc/mysql/my.cnf,改为:datadir = /usr/local/mysql

2.cp -a /var/lib/mysql /usr/local/

3./etc/init.d/mysql start

问题出现了,系统报错了,无法启动mysql,日志显示为:Can't find file: "./mysql/plugin.frm'(errno:13)

[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

但是执行mysql_upgrade时,同样报错。

在网上google一圈后,没有找到解决办法。

忽然想起,之前在调试mail server时,,修改系统默认存储目录,需要修改系统的chroot参数,于是决定试下,后面事实证明就是这个原因。这里把相关步骤记录下,以备需要的朋友共享之。

修改系统的chroot,需要修改/etc/apparmor.d下的相关文件,这里以mysql为例,需要修改:usr.sbin.mysqld和abstractions/mysql两个文件。

1.修改usr.sbin.mysqld里面的两行内容:/var/lib/mysql/ r,改为:/usr/local/mysql/ r,/var/lib/mysql/** rwk,改为:/usr/local/mysql/** rwk,

2.修改abstractions/mysql中一行:/var/lib/mysql/mysql.sock rw,改为:/usr/local/mysql/mysql.sock rw,

3.重新加载apparmor服务:/etc/init.d/apparmor reload

这时再启动mysql就成功了!

启示:不只是mysql,如果需要修改其他一些系统自带软件的存储目录,改了配置之后,仍然报错的话,则可能需要修改相应chroot才行!请参照上面的方法!

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template