【发布时间】:2014-04-12 23:52:28
【问题描述】:
我有一个单独的分区来保存我的 www 和 mysql 文件夹。
我将该分区设置为启动时自动挂载,并且 apache2 启动正常,没有错误。
但是,当我最近删除了mysql-server-5.5的所有痕迹时,重新启动然后重新启动它,它会正常工作。
但是第二次我将 my.cnf 更改为指向 /media/server/mysql,并尝试启动 mysql 然后它就出错了。
这是我到目前为止所遵循的步骤列表。请注意,据我所知,Debian 没有 apparmor,所以我跳过了这一步。
Stop MySQL using the following command:
sudo /etc/init.d/mysql stop
Copy the existing data directory (default located in /var/lib/mysql) using the following command:
sudo cp -R -p /var/lib/mysql /newpath
edit the MySQL configuration file with the following command:
gedit /etc/mysql/my.cnf
Look for the entry for datadir, and change the path (which should be /var/lib/mysql) to the new data directory.
In the terminal, enter the command:
sudo gedit /etc/apparmor.d/usr.sbin.mysqld
Look for lines beginning with /var/lib/mysql. Change /var/lib/mysql in the lines with the new path.
Save and close the file.
Restart the AppArmor profiles with the command:
sudo /etc/init.d/apparmor reload
Restart MySQL with the command:
sudo /etc/init.d/mysql restart
Now login to MySQL, and you can access the same databases you had before.
来自How to change MySQL data directory?
虽然我也看过这里的链接https://askubuntu.com/questions/137424/moving-mysql-datadir
我的猜测是这是一个权限问题,但我可能是错的。
root@debian:~# chown -R mysql:mysql /media/server/mysql
root@debian:~# sudo /etc/init.d/mysql restart
[ ok ] Stopping MySQL database server: mysqld.
[FAIL] Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed!
我承认我还是 linux 的新手,所以我可能正在做其他人推荐的事情,但我并没有真正了解它到底在做什么。
它没有详细说明失败的原因。
我可能考虑做的另一个选择是重新启用它以使用默认数据目录,然后从分区中复制 mysql 文件。
但这否定了为 webdev 提供专用分区的全部意义。
感谢任何 cmets 或努力,谢谢。
【问题讨论】:
-
你复制了“mysql”数据库吗? (mysql在哪里存储它的各种内部数据?)
-
你能给我们看看mysql的日志输出吗!!
-
我最初在一周左右之前,将整个现有的 mysql 数据库和文件复制到了新分区。然后出现了一些错误,mysql拒绝再次启动,因此,从那时起所有的努力。目前没有生成日志文件,在 my.cnf 中该日志部分已被注释掉。但是当我尝试取消注释时,它仍然无法运行以允许我生成日志文件错误消息。但是当我 cat mysql.err 或 mysql.log 时,我得到的只是空文件。