5

I have a separate partition that holds both my www and mysql folders.

I have that partition set to automount at boot, and the apache2 starts fine, no errors.

However, when I just recently removed all traces of mysql-server-5.5, rebooted then restarted it, it would work normally.

But the second I make changes to my.cnf to point to /media/server/mysql, and try to start mysql then it error's out.

Here is the list of steps I have followed so far. Be advised, that Debian does not have apparmor, as far as I know, so I skipped that step.

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.

from How to change MySQL data directory?

Although I also looked at the link here https://askubuntu.com/questions/137424/moving-mysql-datadir

My guess is that this is a permissions issue, but I could be wrong.

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!

I'll admit I am still a newb at linux, so I may be doing things, that other's recommend, without really understanding what it is really doing.

It gives no details about why it is failing.

One other option, I may consider doing, is re-enable it to use the default data dir, and then just copy mysql files back from the partition.

But that denies the whole point of having a dedicated partition for webdev.

I appreciate any comments or efforts, thank you.

3
  • did you copy the "mysql" database? (where mysql is storing its various internal data?) Commented Mar 10, 2014 at 1:30
  • can you show us the mysql log output !! Commented Mar 10, 2014 at 1:40
  • I had originally a week or so ago, copied the whole existing mysql database and files to the new partition. Then some error came up, and mysql refused to start up again, hence, all the efforts since then. Currently there is no log file being generated, in the my.cnf that log section is commented out. But when I try to uncomment it, it still won't run to allow me to generate a log file error message. But when I cat mysql.err or mysql.log all i get is empty files. Commented Mar 10, 2014 at 2:30

2 Answers 2

7

Instead of copying your original datadir (/var/lib/mysql), you should move it. It keeps better track on all metadata.

Insted of:

sudo cp -R -p /var/lib/mysql /newpath

use:

sudo mv /var/lib/mysql /newpath

or better save a copy of your original datadir and then move it, like this:

sudo cp -R -p /var/lib/mysql /var/lib/mysql.bak
sudo mv /var/lib/mysql /newpath

Then start mysql service, it should all go smoothly :)

Cheers!

Sign up to request clarification or add additional context in comments.

1 Comment

I cp the old datadir and then tried to chown -R mysql:mysql which didn't work. When I copied the mysql directory as above I was able to restart mysql.
0

I encountered the same problem, but after a short investigation. I noticed that the mysql deamon failed because of the bin-logs.

So I edited the file "mysql-bin.index" in the datadirectory and updated the location of the bin files to the new datadirectory.

Now mysql did start without any issues.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.