我有一个单独的分区,其中包含我的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提供专用分区的全部意义。
我很感谢你的评论和努力,谢谢。
发布于 2015-05-27 19:45:54
您应该移动它,而不是复制原始数据目录(/var/lib/mysql)。它可以更好地跟踪所有元数据。
例举:
sudo cp -R -p /var/lib/mysql /newpath使用:
sudo mv /var/lib/mysql /newpath或者最好保存原始数据目录的副本,然后移动它,如下所示:
sudo cp -R -p /var/lib/mysql /var/lib/mysql.bak
sudo mv /var/lib/mysql /newpath然后启动mysql服务,应该一切顺利:)
干杯!
发布于 2017-01-06 08:25:39
我遇到了同样的问题,但经过短暂的调查之后。我注意到mysql守护程序因为bin-logs而失败。
因此,我在datadirectory中编辑了文件"mysql-bin.index“,并将bin文件的位置更新到新的datadirectory中。
现在mysql确实启动了,没有任何问题。
https://stackoverflow.com/questions/22290655
复制相似问题